import java.util.Random; public class test { public static void main(String[] args) { Random random=new Random(); int [][] array=new int[5][5]; for(int i=0;i<5;i++){ for(int j=0;j<5;j++){ array[i][j]=random.nextInt(100); System.out.print(array[i][j]+" "); } System.out.print(" "); } for(int i=0;i<array.length;i++){ for (int j = 0; j <array[i].length; j++){ System.out.println(array[i][j]); } } } }
执行效果
65 93 90 45 32 22 97 49 34 53 81 39 98 66 21 22 82 45 85 49 6 97 61 20 32 65 93 90 45 32 22 97 49 34 53 81 39 98 66 21 22 82 45 85 49 6 97 61 20 32