I am trying to write a code for multidimensional array, allocate memory for variables and access the value of the arrays. I want them to be shown as rows and columns. but my code only shows one column and no rows.
here is my code:
public static void main(String[] args) {
int[ ][ ] aryNumbers = new int[2][2];
aryNumbers [0][0] = 1;
aryNumbers [0][1] = 2;
aryNumbers [1][0] = 3;
aryNumbers [1][1] = 4;
int rows = 2;
int columns = 2;
int i,j;
for(i=0;i<rows;i++){
for(j=0;j<columns;j++){
System.out.println(aryNumbers[i][j] + " ");
}
System.out.println(" ");
}
the output i get is:
1
2
3
4
the output i want is:
1 2
3 4
Any help would be really appreciated. thanks in advance