Its very easy to get the 2nd highest element in an array. I've shows below for all your reference. Hope this will be helpful.
import java.util.Arrays;
public class Testdemo {
public static void main(String[] args) {
int[] numbers = {1, 5, 4, 2, 8, 1, 1, 6, 7, 8, 9};
Arrays.sort(numbers);
System.out.println("The second Higest Element :" + numbers[numbers.length-2]);
}
}
Ans - The second Higest Element :8