Thomas ClassiFied Thomas ClassiFied - 1 year ago 138
Java Question

Trim and Lowercase

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

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 Source

They don't trim or lowercase "in-place"

You could just put it in the print statement, though

System.out.println("\"" + sentence.trim().toLowerCase() + "\"" + " ---> ");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download