Collections求数组最值

来源:互联网 发布:帝国年代2 java 编辑:程序博客网 时间:2024/05/18 01:51
Integer[] numbers = { 8, 2, 7, 1, 4, 9, 5};
int min = (int) Collections.min(Arrays.asList(numbers));
int max = (int) Collections.max(Arrays.asList(numbers));
System.out.println("最小值: " + min);
System.out.println("最大值: " + max);
原创粉丝点击