Three Dimensional Array program

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

Three Dimensional Array program

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

Three Dimensional Array program

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