Each String Object Holds its own Data

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page

Must all the Strings be of the same length?

Answer:

No. Each element of the array is of the same type a reference to a String, but the Strings themselves can be of different lengths.

Each String Object Holds its own Data

array of string references

 

Each String object in the example is an ordinary String. Nothing about it has changed because its reference is held in an array. Each String can have any number of characters. The picture shows this.

There is no requirement to fill the array in order. Often this is done to make further work easier, but Java does not require it.

QUESTION 5:

Add a reference to "the end" to the last cell of the array.