Sir neenga potta methodku sorted orderla value kuduthaa correctaa answer varala So first conditionla If(a1[i]>max) { secondmax=max; max=a1[i]; } Second condition is correct First condition la naan add panna maadhiri add pannikonga Appo dhaan ungalukku sorted orderla pottaa dhaan answer correctaa varum
Public class maximum{ Public static void main String[]args { int[]a1={2,5,7,8,9}; int max=0; int secondmax=0; for(int i=0; imax) { secondmax=max; max=secondmax; } else if(a1[i]>secondmax) { secondmax =a1[i]; } } System.out.println( " The maximumvalue is: "+max); System.out.println(" The second maximum value is: "+secondmax); }}