[CODE=java]
public class test{
public static void main()
{
a1(new int[]{1, 2, 3, 4});
}
static int a1(int[] a)
{
int max1 = -1;
int max2 = -1;
for (int i=0; i<a.length; i++)
{
if (a[i] > max1)
{
max2 = max1;
max1 = a[i];
}
else if (a[i] != max1 && a[i] > max2)
max2 = a[i];
}
return max2;
}
}// end of class test
[/CODE]
please help me what is wrong with this code, my compiler generates error in the third line that as '( 'and ')'are expected , thank you all !!
public class test{
public static void main()
{
a1(new int[]{1, 2, 3, 4});
}
static int a1(int[] a)
{
int max1 = -1;
int max2 = -1;
for (int i=0; i<a.length; i++)
{
if (a[i] > max1)
{
max2 = max1;
max1 = a[i];
}
else if (a[i] != max1 && a[i] > max2)
max2 = a[i];
}
return max2;
}
}// end of class test
[/CODE]
please help me what is wrong with this code, my compiler generates error in the third line that as '( 'and ')'are expected , thank you all !!
Comment