The array taking more than one subscripts is known as multi-dimensional array.
Multidimensional arrays are represented in the form of array of array with each element of the array holding the reference of other array. These are also known as Jagged Arrays.
A multidimensional array is created by appending one set of square brackets ([]) per dimension.
int[][] arr = new int[10][20]; //a 2D array int[][][] arr = new int[10][20][10]; //a 3D array
MultiDimensionalDemo.java
class MultiDimensionalDemo { public static void main(String[] args) { // declaring and initializing 2D array Int[][] arr = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; // printing 2D array for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) System.out.print(arr[i][j] + " "); System.out.println(); } } }
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc