how to initialise 2d array in java code example
Example 1: 2d arrays | java
int[][] arr = new int[row][column];
Example 2: How to create a 2d array in java
int[][] arr = new int[m][n];
Example 3: two dimensional array in java example program
class MultidimensionalArray {
public static void main(String[] args) {
int[][] a = {
{1, -2, 3},
{-4, -5, 6, 9},
{7},
};
for (int[] innerArray: a) {
for(int data: innerArray) {
System.out.println(data);
}
}
}
}
Example 4: how to initialize one dimensional array in java
int[] a;
int b[];
int[] c;