Does Java support multi-dimensional Arrays?

JavaObject Oriented ProgrammingProgramming

No, Java does not support multi-dimensional arrays.

  • Java supports arrays of arrays.
  • In Java, a two-dimensional array is nothing but, an array of one-dimensional arrays.

                  int[][] arr = new int[2][4];

  • The expression arr[i] selects the one-dimensional array and the expression arr[i][j] selects the element from that array.
  • Array indices in each dimension range from zero to "length". Where length is the array length in the given dimension. 
  • There is no array assignment operator. The number of dimensions and the size of each dimension is fixed once the array has been allocated.
Published on 29-May-2019 17:20:50