Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello i wana define a 4d and 5d array in java

int[][][][] arr1 = new int[2][2][2][2];
Posted
Updated 3-Jun-12 23:50pm
v2

Is not working is a really poor description.
What is the problem you are experiencing with such code?

this code
Java
int four[][][][] = new int[2][2][2][2];
int i,j,k,l;
for (i=0; i<2; i++)
  for (j=0; j<2; j++)
    for (k=0; k<2; k++)
      for (l=0; l<2; l++)
      {
        four[i][j][k][l]= (i+1)*(j+1)*(k+1)*(l+1);
        System.out.println(four[i][j][k][l]);
      }
  System.out.println("");


works for me.
 
Share this answer
 
Java
int[][][][] a2 = new int[2][3][3][4];
 // print array in rectangular form
   for (int i=0; i<a2.length; i++) {
     for (int j=0; j<a2[i].length; j++) {
         for (int x=0; x<3; x++){
             for (int y=0; y<3; y++){
                System.out.print(" " + a2[i][j][x][y]);
             }
         }
     }
     System.out.println("");
   }
 }


I GOT IT  THNX
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900