Multidimensional Arrays - Java Language Basics

Java examples for Language Basics:Array

Introduction

Arrays can be multidimensional.

Multidimensional Arrays contain more than one subscript.

Multidimensional Arrays can store information in multiple dimensions.

Multidimensional array can represent the data in an (x,y) grid of array elements.

The following statement contains a three-dimensional array of integers and displays the number of elements in each dimension:

Demo Code

public class Main {
  public static void main(String[] arguments) {
    int[][][] cen = new int[100][52][7];
    System.out.println("Elements in 1st dimension: " + cen.length);
    System.out.println("Elements in 2nd dimension: " + cen[0].length);
    System.out.println("Elements in 3rd dimension: " + cen[0][0].length);

  }//w w  w  .  j  a v a2s  . c om
}

Result


Related Tutorials