Friday 19 April 2019

java - Trim and Lowercase




Every time I try doing the trim method and the lowercase method it doesn't show the way I want it.



sentence.trim();
sentence.toLowerCase();
System.out.println("\"" + sentence + "\"" + " ---> ");


For example, if I input " Hello World! ", it will print out " Hello World! " and not use any of the methods.



Answer



You need to store the value returned:



sentence = sentence.trim().toLowerCase();

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...