Hi,
This code should would work:
public class Trial {
public Trial() {
}
public static void main(String[] args){
int row_length =4;
int col_length =3;
int ver_length =2;
int SpacePoint[][][]= new int[row_length][col_length][ver_length];
for(int counterROW=0;counterROW<row_length;counterROW++){
for(int counterCOL=0;counterCOL<col_length;counterCOL++){
for(int counterVer=0;counterVer<ver_length ;counterVer++){
SpacePoint[counterROW][counterCOL][counterVer]
=counterROW+counterCOL+counterVer;
System.out.print(SpacePoint[counterROW][counterCOL]
[counterVer]);
}
}
}
}
}
Change: From row_length++ in for loop to counterROW++
Change: From ver_length++ in for loop to counterVer++
You were incrementing the array length which was a no-no.
Cheers,
Casey Coppock
On Jan 30, 3:50 pm, Stephen Adjei <[email protected]> wrote:
> I run this code and it didnt print out anything but froze my machine:
> why.does that mean home pc's cant process three D arrays
>
> public class Trial {
>
> public Trial() {
> }
> public static void main(String[] args){
> int row_length =4;
> int col_length =3;
> int ver_length =2;
>
> int SpacePoint[][][]= new int[row_length][col_length][ver_length];
>
> for(int counterROW=0;counterROW<row_length;row_length++){
> for(int counterCOL=0;counterCOL<col_length;counterCOL++){
> for(int counterVer=0;counterVer<ver_length ; ver_length++){
>
> SpacePoint[counterROW][counterCOL][counterVer]=counterROW+counterCOL+counterVer;
> System.out.print(SpacePoint[counterROW][counterCOL][counterVer]);
>
> }
> }
>
> }
>
> }
>
> I need some help on three dimensional array
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---