这可以在一行上打印数字,但我想格式化数组,以便每行有20个数字。我该怎么做呢?
Random r = new Random();
int[] myArray = new int[1000];
for (int counter = 0; counter < myArray.length; counter++) {
int store = 10 + r.nextInt(89);
myArray[counter] = store;
System.out.print(myArray[counter]);
}
答案 0 :(得分:0)
Random r = new Random();
int[] myArray = new int[1000];
for (int counter = 0; counter < myArray.length; counter++) {
int store = 10 + r.nextInt(89);
myArray[counter] = store;
if(counter != 0 && counter % 20 == 0)
System.out.print("\n");
System.out.print(myArray[counter] + " ");
}