adsense


Saturday, 24 October 2015

JAVA EXAMPLES DIMENSION OF ARRAY PAGE 46

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button



JAVA EXAMPLES DIMENSION OF ARRAY




Java Examples - Dimension of Array


Problem Description:
How to determine the upper bound of a two dimensional array ?
Solution:
Following example helps to determine the upper bound of a two dimensional 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


Java Examples - Dimension of Array


Problem Description:
How to determine the upper bound of a two dimensional array ?
Solution:
Following example helps to determine the upper bound of a two dimensional 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



No comments: