Java ArrayList получит вторую по величине ценность
public class Main {
public static void main(String[] args) {
// Find the 2nd largest value in a ArrayList
ArrayList<Integer> numbers = new ArrayList<>(Arrays.asList(101, 222, 4829, 352, 8238, 2835, 29));
Collections.sort(numbers);
int secondLargestNumber = numbers.get(numbers.size() - 2);
System.out.println(secondLargestNumber);
}
Herker