7.6 Arrays of Strings

To create an array of strings, you declare an array as follows :

String[] fruits = new String[3];

This statement declares and instantiates fruits that can contain 3 elements, wherein each element of fruits is a reference to a String object.
Next, consider the statement:

fruits[0] = "Mango";

This statement creates a String object with the value "Mango" and stores the address of the object into fruits[0].

Similarly, the following statements assign String objects, with the given values, to the other elements of fruits array:

fruits[1] = "Apple";
fruits[2] = "Banana";

Following figure explains this :