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 + "]";
Joined: Mar 22, 2005
I think "info[k].length" should read "info[i].length" instead.
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.