在由第一个和最后一个索引确定的子数组中找到可比的最小值。
//package com.nowjava; /* from n o w j a v a . c o m*/ public class Main { /** Find the smallest Comparable in a subarray determined by * indices first and last. * * @param a the array * @param first the index of the first element of the subarray * @param last the index of the last element of the subarray * @return the index of the smallest element of the subarray */ public static <T extends Comparable<? super T>> int getIndexOfSmallest( T[] a, int first, int last) { int smallest = first; for (int index = first + 1; index <= last; index++) {