hi, i have the following 2d array:
Object[][] data =
{
{new Boolean(false), "Mary", new Date(), "Snowboarding", new
Integer(5) },
{new Boolean(true), "Alison", new Date(), "Rowing", new Integer(3) },
{new Boolean(false), "Kathy", new Date(), "Knitting", new Integer(2)
},
{new Boolean(true), "Sharon", new Date(), "Speed reading", new
Integer(20) },
{new Boolean(false), "Philip", new Date(), "Pool", new Integer(10) }
};
and the following method to print out a 2d array:
private static void prtArray(Object[][] array)
{
for(int i = 0; i < array.length; i++)
{
System.out.println("");
for(int y = 0; i < array[i].length; y++)
{
System.out.print(array[i][y] + ", ");
}
}
System.out.println("---------------------------------------");
}
but when i invoke prtArray(data);, it gave me the following output:
false, Mary, Wed May 25 13:33:34 EDT 2005, Snowboarding, 5, Exception
in thread "main" java.lang.ArrayIndexOutOfBoundsException
at Test.prtArray(Test.java:75) -- the line is:
System.out.print(array[i][y] + ", ");
anyone know what's wrong?
Roland - 25 May 2005 18:40 GMT
[snip]
> for(int y = 0; i < array[i].length; y++)
*
probably should be:
for(int y = 0; y < array[i].length; y++)

Signature
Regards,
Roland de Ruiter
___ ___
/__/ w_/ /__/
/ \ /_/ / \
Locke - 25 May 2005 20:06 GMT
Exactly - it is always some mundane thing that causes the biggest problems.
Locke
> [snip]
>> for(int y = 0; i < array[i].length; y++)
> *
> probably should be:
> for(int y = 0; y < array[i].length; y++)