If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

all those strings, are different just by the number. now suppose i did this:
String[] s = new String[3];
String s[0] = "string zero";
String s[1] = "string one";
String s[2] = "string two";

whats changed? well.. nothing really, except a few extra []. its still a name, yes?
when a proper number is combined with the name of the array, it becomes part of the name. the only difference is, we can insert the number during the operation of the program, instead of before compilation, yes?

so you accept that s[0] is just the name of a string, just like s0 is.

heres how you use them in a loop:

Code:

for(int i=0; i<s.length; i++){
s[i] = "string "+i;
}

java will replace the i with 0, then 1, then 2.. all the time, amking names

-

now, its no different for 2D arrays.. except that this time, our first array isnt going to hold Strings.. its going to hold other arrays (see the pic)

the important thing here is that the first loop, with I in it, deals with the first array.. the array that holds arrays
so each name in that ss[0], ss[1] and ss[2] .. is the name of another array. and it is that another array that holds the strings.. so to get to the string.. we put an index on the name.
remember that the name is ss[0] .. put an index on it:
ss[0][0]

the bold bit is the index that gets us access to the string, the other bit is the name of the current array.. see how this works, with arrays of arrays?