import java.util.Random; public class HomeWork4 { public static void main(String[] args) { int[][] arr = new int[5][5]; Random random = new Random(); for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr[i].length; j++) { arr[i][j] = random.nextInt(100)+1; } } System.out.println("打印二维数组:"); for (int[] a : arr) { for (int b : a) { System.out.print(b + " "); } System.out.println(); } System.out.println(); int max = arr[0][0]; for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr[i].length; j++) { if (arr[i][j] > max) { max = arr[i][j]; } } } System.out.println("最大值是:" + max); } }