End of the Chapter

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.

Answer:

There is nothing wrong with the program. Since color is a primitive data type, an expression such as

color == 'V'

compares the contents of color (a character) to the character literal 'V'. However, the following would be wrong:

color == "V"

This is asking to compare the character value in color with a reference to the String object "V".

End of the Chapter

This is the end of the chapter. A strong case can be made for reviewing the following subjects.

The next chapter will discuss the do statement.

You have reached the end of the chapter.

go to previous page   go to home page