Multi-Dimensional Array

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. Examples:

 

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();
  }
 }
}

 

Our Services:

Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Data Science with Python Training | Projects

SILAN Technology, BBSR
Call to: 9439202111  |  9658317757  |  0674-2361252

Comment