The toLowerCase() Method

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        

Answer:

It creates a new String which is a lower case version of the original string.

The toLowerCase() Method

Look at these lines of code:

     String burns = "My love is like a red, red rose.";

     . . . . . .

     if ( burns.toLowerCase().startsWith( "  MY LOVE".trim().toLowerCase() ) )
       System.out.println( "Both start with the same letters." ); 
     else
       System.out.println( "Prefix fails." );

QUESTION 28:

What does the above write to the monitor?