先创建一个二维数组,讲数字1~255存入这个二维数组中,顺序是从左到右,从上到下,由1开始。
public class TestMain {
public static void main(String[] args) throws Exception {
int[][] arr = new int[255 / 5][5];
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
arr[i][j] = (i * 5) + (j + 1);
}
}
for (int[] ints : arr) {
for (int i : ints) {
System.out.print(i + "\t");
}
System.out.println();
}
}
}