2d matrix size java code example
Example 1: 2d array length in java
public static void main(String[] args) {
int[][] foo = new int[][] {
new int[] { 1, 2, 3 },
new int[] { 1, 2, 3, 4},
};
System.out.println(foo.length);
System.out.println(foo[0].length);
System.out.println(foo[1].length);
}
Example 2: java length of matrix
public static void main(String[] args) {
int[][] foo = new int[][] {
new int[] { 1, 2, 3 },
new int[] { 1, 2, 3, 4},
};
System.out.println(foo.length);
System.out.println(foo[0].length);
System.out.println(foo[1].length);
}