Tutorials Point


  Java Basics Examples
  Java Tutorial
  Java Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

Java Examples - Dimension of Array


previous next AddThis Social Bookmark Button


Advertisements

Problem Description:

How to determine the upper bound of a two dimentional array ?

Solution:

Following example helps to determine the upper bound of a two dimentional array with the use of arrayname.length.

public class Main {
   public static void main(String args[]) {
      String[][] data = new String[2][5];
      System.out.println("Dimension 1: " + data.length);
      System.out.println("Dimension 2: " + data[0].length);
   }
}

Result:

The above code sample will produce the following result.

Dimension 1: 2
Dimension 2: 5


previous next Printer Friendly

Advertisements


  

Advertisements