Multidimensional array in Java

Java Programming Java8Object Oriented Programming

Example

Following is a simple example of a multi-dimensional array. 

Live Demo

public class Tester {
   public static void main(String[] args) {
      int[][] multidimensionalArray = { {1,2},{2,3}, {3,4} };
     
      for(int i = 0 ; i < 3 ; i++){
         //row
         for(int j = 0 ; j < 2; j++){
            System.out.print(multidimensionalArray[i][j] + " ");
         }
         System.out.println();
      }
   }
}

Output

1 2
2 3
3 4
raja
Published on 23-Apr-2018 11:58:22
Advertisements