strArray[1] = "World" ;
Recall these facts about all arrays:
Frequent Bug: It is easy to confuse the length of an array with the number
of slots that contain a reference.
In the example, only two slots contain references to Strings, but
strArray.length
will be 8.
Here is a section of code that declares and constructs the array, and puts some more Strings into it:
String[] strArray = new String[8] ; // combined statement strArray[0] = "Hello" ; strArray[1] = "World" ; strArray[2] = "Greetings" ; strArray[3] = "Jupiter" ;