A good answer might be:

Looks like a good place for an array.

Array of String References

 

You can declare an array of String references:

String[] strArray;          // 1.

This declares a variable strArray which in the future may refer to an array object. Each slot of the array may be a reference to a String object (but so far there is no array.)

To create an array of 8 String references do this:

strArray = new String[8] ;  // 2.

Now strArray refers to an array object. The array object has 8 slots (elements.) However none of the slots refer to an object (yet.) The slots of an array of object references are automatically initialized to null, the special value that means "no object."

Now, to actually create a String and store its reference in slot zero of the array, do this:

strArray[0] = "Hello" ;     // 3.

Remember that with String objects you don't have to explicitly use new (it happens automatically.)

 


QUESTION 3:

Put the string "World" in slot 1 of the array.