[code]
   for (int i = 0; i<ages.length; i++)
        {
            System.out.println("\nStarting Row "  +i);
            for(int j = 0;j<ages[i].length;j++)
            {
                for(int k = 0;k<ages[i][j].length; k++)
                {
                     ages[i][j][k] = i * j * k;
                     System.out.print(ages[i][j][k] + " ");
                }
            }
        }
[code]

______________________________________________



<:3~   <--- Dinu :)
______________________________________________

--- On Sun, 8/9/09, Quentin <[email protected]> wrote:

From: Quentin <[email protected]>
Subject: [java programming] three dimensional array LAB 1036
To: [email protected]
Date: Sunday, August 9, 2009, 11:47 PM




 
 






Good day all 

   

I have a problem with this three dimensional array. 

   

Any suggestions? 

   

[code] 

   

public static void main(String[] args) { 

        // TODO code application logic here 

        int[][][] ages = new int[10][5][2]; 

   

        System.out.println("ages.length =
"+ages.length); 

        System.out.println("ages[1].length =
"+ages[1].length); 

        System.out.println("ages[2].length =
"+ages[2].length); 

   

        for (int i = 0; i<ages.length; i++) 

        { 

            System.out.println("\nStarting Row " 
+i); 

   

            for(int j = 0;j<ages[i].length;j++) 

            { 

                for(int k = 0;k<ages[k].length; k++) 

                { 

                     ages[i][j][k] = i * j * k; 

                     System.out.println(ages[i][j][k] +
" "); 

                } 

            } 

        } 

    } 

[/code] 

   

My error message I receive is 

   

[error] 

   

ages.length = 10 

ages[1].length = 5 

ages[2].length = 5 

   

Starting Row 0 

0  

0  

Exception in thread "main"
java.lang.ArrayIndexOutOfBoundsException: 2 

        at TwoDimensionArray.main(TwoDimensionArray.java:31) 

Java Result: 1 

BUILD SUCCESSFUL (total time: 0 seconds) 

 

[/error] 

   

REGARDS 

Quentin 

   

FINGER
MONEY 

http://www.fingermoney.co.za 

   







 






      
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to