Find second largest element in the array
Anoniem
private static void printSecondHighest(int[] arr) { int first = Integer.MIN_VALUE; int second = Integer.MIN_VALUE; for(int num: arr){ if(num > first){ second = first; first = num; } else if(num second){ second = num; } } System.out.println(second); }