public static int secHigh(int arr[]){ int firstHigh = 0,secHigh = 0; for(int x: arr){ if(x > firstHigh){ secHigh = firstHigh; firstHigh = x; }else if(x > secHigh){ secHigh = x; } } return secHigh; }