Lire tableau bidimensionnel
Bonjour j'aborde les tableaux en deux dimensions et je n'arrive pas à lire celui-ci : je pensais qu'un System.out.print(matrix[i][j]); m'aurait permis de lire le contenu mais ça n'est pas le cas.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| public static void main(String[] args) {
int[][] matrix = new int[2][3];
int a[] = {1, 2, 3};
int b[] = {4, 5, 6};
int j = 0;
for(int i = 0;i<matrix.length; i++ ) {
for(j = 0; j<matrix[i].length; j++) {
System.out.print(matrix[i][j]);
}
System.out.print("\n");
} |
Merci à vous