Looks like a good place for an array.
You can declare an array of
String strArray; // 1.
This declares a variable
which in the future may refer to an
Each cell of the array may be a reference
(but so far there is no array).
To create an array of 8
String references do
strArray = new String ; // 2.
strArray refers to an array object.
The array object has 8 cells.
However none of the cells refer to an object (yet).
The cells of an array of object references are automatically
initialized to null,
the special value that means
String reference in cell zero of the
array, do this:
strArray = "Hello" ; // 3.
You don't have to explicitly use the
to get a reference to a
(If a suitable object already exists, you get a reference to that object.
Otherwise an object is constructed and you get a reference to it.)
String literals in chapter 26 if this is not clear.
Write a statement that puts a reference to "World" in cell 1 of the array.