How to find the max value of an Arraylist and two of its Index position using Java
问题 How can I find the maximum value from an Arraylist with its index positions? ArrayList ar = new ArrayList(); ar.add(2); // position 0 ar.add(4); // position 1 ar.add(12); // position 2 ar.add(10); // position 3 ar.add(12); // position 4 String obj = Collections.max(ar); int index = ar.indexOf(obj); System.out.println("obj max value is " + obj + " and index position is " + index); The above program just returns the output as the first max object with value 12 and index position 2 . But my