package javaapplication1;
public class JavaApplication1 {
public static void main(String[] args) {
int row = 3;
int col = 4;
int[][] arr2d = new int[row][col];
arr2d[0][0] = 100;
arr2d[1][1] = 11;
arr2d[2][2] = 22;
arr2d[2][3] = 8888;
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++)
{
System.out.print(arr2d[i][j] + " ");
}
System.out.println();
}
System.out.println();
int[] arr1d = new int[row * col];
arr1d[0 * col + 0] = 100;
arr1d[1 * col + 1] = 11;
arr1d[2 * col + 2] = 22;
arr1d[2 * col + 3] = 8888;
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++)
{
System.out.print(arr1d[i * col + j] + " ");
}
System.out.println();
}
}
}
/*
run:
100 0 0 0
0 11 0 0
0 0 22 8888
100 0 0 0
0 11 0 0
0 0 22 8888
*/