- public class ArrayDemo {
- public static void main(String[] args) {
- int[][] array = new int[][] {{55, 5, 23, 15},
- {10, 2, 88, 33},
- {23, 22, 1, 78},
- {13, 14, 53, 16}};
- System.out.println("最小值 : " + getMin(array));
-
- }
- //获取二维数组中的最小值
- public static int getMin(int[][] array) {
- int temp = array[0][0];
- for (int i = 0; i < array.length; i++) {
- for (int j = 0; j < array[i].length; j++) {
- if(temp > array[i][j])
- temp = array[i][j];
- }
- }
- return temp;
- }
- }
复制代码 |