This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
I need code for 3 dimensional array . The following code throws ArrayIndexOutofBounds Exception.
change return type as integer array not string array. I am new to array concepts.need to print 3 rows and 3 columns
String info = new String;
for (i=0; i<info.length ; i++)
for (j=0 ; j<=3; j++)
info[i][j][k] = "String[" + i + "," + j + "," + k + "]";
I think "info[k].length" should read "info[i].length" instead.
Ping & DNS - updated with new look and Ping home screen widget
Joined: Sep 10, 2009
From the following code , i need to print all 3 s like 3 3 3
3 3 3
3 3 3
int a2 = new int;
for (i=0; i<a2.length; i++)
for (j=0; j<a2[i].length; j++)
System.out.print(" " + a2[i][j]);
Sean Clark wrote:He was so close, so I apologise if anyone thinks I am giving out the answer.
There's no ambiguity, you gave out the answer. Consider next time dropping a hint, like "what's the highest allowable index for an array of size n" or something similar--the more thought process involved the more retention, and understanding, there is. When the answer is given out, there's less thought involved, even though the solution is the same.