how to initialize a nested array in java code example

Example 1: accessing 2d array in java

(m x n matrix) - (2 x 3 matrix)  
m	n ------------------ >
|	a[0][0] a[0][1] a[0][2]
v	a[1][0] a[1][1] a[0][2]

Example 2: Multidimensional array in java

// java two dimensional array length example
public class TwoDimensionalArrayLength
{
   public static void main(String[] args) 
   {
      int[][] arrNumber = { 
              { 1, 3, 5 },
              { 7, 9, 2 },
              { 1, 2, 3, 4, 5 } };
      System.out.println("Java two dimensional array length: " + arrNumber.length);
   }
}

Tags:

Java Example