go to previous page   go to home page  
     String burns = "My love is like a red, red rose.";
     . . . . . .
     if ( burns.toLower().startsWith( "  MY LOVE".trim().toLower() ) )
         System.out.println( "Both start with the same letters." ); 
     else
         System.out.println( "Prefix fails." );

Answer:

Both start with the same letters.

" MY LOVE".trim().toLowerCase() creates the temporary string "my love" .

"burns.toLower() creates the temporary string "my love is like a red, red rose."

Both strings start out the same.


End of the Chapter

That was a complicated question. I hope you rose to the occasion. If you got burned, review the example. You may wish to review the following.


You have reached the end of the chapter.

go to previous page   go to home page