import java.util.Arrays;
public class Test1 {
public static void main(String[] args) {
int[] ary = {23, 43, 21, 67, 33, 89, 70};
Arrays.sort(ary);
int max = ary[ary.length-1];
int min = ary[0];
System.out.println("最大值是:" + max);
System.out.println("最小值是:" + min);
System.out.println("差值是:" + (max - min));
}
}
运行结果
最大值是:89
最小值是:21
差值是:68
温馨提示:内容为网友见解,仅供参考