0

i want to find the second smallest number ib array but it is displaying second highest number

int max=0,second=0;

if(a[0]>a[1])

{

max=a[0];

second=a[1];

}

else

{

max=a[1];

second=a[0];

}

for( i=2;i<n;i++)

{

if(a*>=max)
{
second=max;
max=a*

*; } else*

if(a*>second)
second=a ;*

}

System.out.println("the second smallest nubmer is"+second);