Three Dimensional Array program

This is a very simple Java program. In this program we will learn how to use three dimensional array.


 

Ads

Tutorials   
Ads

Three Dimensional Array program

     

This is a very simple Java program. In this program we will learn how to use three dimensional array. Firstly, we have to define class name "ThreeDMatrix" . We are going to create 3 by 4 by 5 program. We are going to make three dimensional array having multi rows and columns.

By using the multidimensional array we are going to make a matrix. Now in this program use the three for loop for multi dimensional array. After that use the display the values by using println() method .

Here is the code of this program

class ThreeDMatrix
{
  public static void main(String[] args
  {
  int threeD[][][] new int[3][4][5];
  int i,j,k;
  for (i=0; i<3; i++)
  for(j=0; j<4; j++)
  for (k=0; k<5; k++)
  threeD[i][j][k]= i*j*k;

  {
  for(i=0; i<3; i++)
  for(j=0; j<4; j++){
  for (k=0; k<5; k++ )
  {
 System.out.print(threeD[i][j][k])
  }
 System.out.println();
  }
  System.out.println();
 }
  }
}

Download this Example

Advertisements

Share on Google+Share on Google+

Three Dimensional Array program

Posted on: June 25, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: Three Dimensional Array program  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:2
Mr.Osoble
November 15, 2011
Java

thank you for your posting three dimentional in java many thanks
karthika
July 15, 2013
comments

i want manual explanation about about three dimensional arrar

Ads

 

Ads