62,620
社区成员
发帖
与我相关
我的任务
分享
// 可以不用那么麻烦,下面是我想的,当然肯定还有更简单的方法。
Integer grades[][] = { { 37, 78, 96, 43 }, { 26, 17, 99, 11 },
{ 40, 90, 86, 81 } };
List<Integer[]> a = Arrays.asList(grades); //将二维数组转化为集合
List<Integer> b = new ArrayList<Integer>();
for(Integer[] x:a){
for(Integer y:x){
b.add(y); // 将全部数字放一个集合中
}
}
System.out.println(Collections.max(b)); //使用jdk提供的工具方法来求最大,最小值。
System.out.println(Collections.min(b));