The title above sums up my question, to clarify things an example is:
array[0] = 1
array[1] = 3
array[2] = 7 // largest
array[3] = 5
so th
one way will be:
Integer[] array = new Integer[4];
array[0] = 1;
array[1] = 3;
array[2] = 7;
array[3] = 5;
List<Integer> iList = Arrays.asList(array);
System.out.println(iList.indexOf(Collections.max(iList)));
System.out.println(iList.indexOf(Collections.min(iList)));
Using Java 8 streams:
List<Integer> list = Arrays.asList(1, 3, 7, 5);
IntStream.range(0, list.size())
.reduce((i, j) -> list.get(i) > list.get(j) ? i : j)
.getAsInt();