import java.util.ArrayList; import java.util.Collections; import java.util.List; class MaxValue { public static void main(String[] args) { Listlist = new ArrayList<>(); list.add(12); list.add(10); list.add(32); list.add(42); list.add(11); list.add(44); int maxValue = (int) Collections.max(list); int maxValueIndex = list.indexOf(Collections.max(list)); System.out.println("Maximum Value: " + maxValue); System.out.println("Maximum Value Indx: " + maxValueIndex); } }
Output:
Maximum Value: 44 Maximum Value Indx: 5