import java.util.Arrays; import java.util.Comparator; public class Test_4_2 { public static void main(String[] args) { Integer[] a = {1,5,6,0,9}; int total = 0; double m = a.length; double Aver = 0.0; for(int i =0; i < a.length;i ++) total += a[i]; Aver = total/m; int min = a[0]; int max = a[0]; for(int i = 0; i < a.length;i ++) if(min > a[i]) min = a[i]; for(int i = 0; i < a.length;i ++) if(max < a[i]) max = a[i]; Arrays.sort(a, new Comparator<Integer>() { @Override public int compare(Integer o1, Integer o2) { return o2.compareTo(o1); } }); System.out.println(Arrays.toString(a)); System.out.println("总数:"+total+" "+"平均分: "+Aver+" "); System.out.println("最大值: "+max+" "+"最小值: "+min); } }