Pin It

How to demonstrate working of Multidimensional Arrays in Java

What do we mean by  Multi-Dimensional Arrays in Java ?. 
Multi-Dimensional Arrays in Java are termed as arrays of arrays. Normal arrays are objects in Java, while if we talk about Multi-Dimensional arrays, those are array objects whose elements themselves store array objects. Two Dimensional arrays are basic representation of tables having rows and columns. Thus, the information stored in two dimensional array is generally in rows and columns. Let us look into a simple program that demonstrate Multidimensional Arrays in Java :- 

package com.hubberspot.multidimensional.array.example; 

public class TwoDimensionalArrayDemo {
  public static void main(String args[]) {
     int twoDArray[][]= new int[5][5];
     int i, j, k = 0;

     for(i=0; i<5; i++)
       for(j=0; j<5; j++) {
         twoDArray[i][j] = k;
     for(i=0; i<5; i++) {
       for(j=0; j<5; j++)
         System.out.print(twoDArray[i][j] + " ");

Output of the program :- 

Please Give Us Your 1 Minute In Sharing This Post!
Related Posts Plugin for WordPress, Blogger...

Post your related queries below ...

comments powered by Disqus
Powered by Blogger.
© 2012 Learn Java by Examples Template by Hubber Spot