dimensions of matrix java code example
Example 1: how to get the dimensions of a 2d array in java
public class Main {
public static void main(String[] args) {
int[][] test = new int[10][4];
int rows = test.length;
int coloumns = test[0].length;
System.out.println(rows);
System.out.println(coloumns);
}
}
Example 2: declare matrix in java
int[][] multi = new int[5][];
multi[0] = new int[10];
multi[1] = new int[10];
multi[2] = new int[10];
multi[3] = new int[10];
multi[4] = new int[10];