原文229页的获取数组的最大最小值的方法,写反了
public class ArrayUtil {
public static class Pair{
private int frist;
private int scend;
public Pair(int frist, int scend)
{
super();
this.frist = frist;
this.scend = scend;
}
public int getFrist() {
return frist;
}
public void setFrist(int frist) {
this.frist = frist;
}
public int getScend() {
return scend;
}
public void setScend(int scend) {
this.scend = scend;
}
public static Pair getMinMax(int[] array)
{
int min = Integer.MIN_VALUE;
int max = Integer.MAX_VALUE;
for (int i : array)
{
if(min >i)min = i;//此处是原文的将不会得到最小值而是Integer.MIN_VALUE
if(max < i)max = i;//不会得到最大值
//以上两处应该把大小于符号调换 } return new Pair(min, max); } } }