A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Programmer Certification (SCJP/OCPJP)
Why is "String".trim() not equal to " String ".trim()
Joined: Sep 14, 2009
Feb 23, 2010 16:38:56
For the following code Equal is printed
if("String".trim() == "String".trim()) System.out.println("Equal"); else System.out.println("Not Equal");
For the following code not equal is printed
if(" String ".trim() == "String".trim()) System.out.println("Equal"); else System.out.println("Not Equal");
Author and ninkuma
Joined: Jan 10, 2002
Feb 23, 2010 16:45:20
Having ignored multiple warnings regarding your display name, your account has been closed.
Asking smart questions
Books by Bear
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Why is "String".trim() not equal to " String ".trim()
q from abhilash mock exam on strings.
Doubts in Strings
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015