您可以使用Collections.min和List.indexOf:
int minIndex = list.indexOf(Collections.min(list));
public static <T extends Comparable<T>> int findMinIndex(final List<T> xs) { int minIndex; if (xs.isEmpty()) { minIndex = -1; } else { final ListIterator<T> itr = xs.listIterator(); T min = itr.next(); // first element as the current minimum minIndex = itr.previousIndex(); while (itr.hasNext()) { final T curr = itr.next(); if (curr.compareTo(min) < 0) { min = curr; minIndex = itr.previousIndex(); } } } return minIndex;}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)