新手不建议用stream流之类的处理方式,可以使用冒泡排序去做,比较清晰理解
public class Test20 {
public static void main(String[] args) {
int[][] szs = {{1, 2, 3, 4},{5, 6, 7}};
for (int[] sz : szs) {
int min = getMin(sz);
System.out.println(min);
}
}
public static int getMin(int[] x){
for (int a = 0; a < x.length; a++){
for (int b = 0;b < x.length - a -1;b++){
if (x[b + 1] < x[b]){
int z = x[b];
x[b] = x[b + 1];
x[b+1] = z;
}
}
}
int min = x[0];
return min;
}
}
int[][] szs = {{1, 2, 3, 4},{5, 6, 7}};
for (int[] sz : szs) {
System.out.println(Arrays.stream(sz).min().getAsInt());
}
哪来的j
为什么有截图非要用手机拍照,真觉得方便人看吗?
getMax getMin方法形参不匹配,而且这个圆括号也是乱的