File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Badass: Making Users Awesome
this week in the
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 agree. 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