File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Boolean comparison Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Boolean comparison" Watch "Boolean comparison" New topic
Author

Boolean comparison

geeta rai
Ranch Hand

Joined: Sep 18, 2003
Posts: 48
Why would
if( new Boolean("true") == new Boolean("true"))
be false?
allison craig
Greenhorn

Joined: Dec 19, 2003
Posts: 17
Hi Geeta. The == operator checks to see if two objects are one of the same at the heap. The "new" operator was used for each operand thus creating two distinct objects. Using ".equals(..)" will result to true.
geeta rai
Ranch Hand

Joined: Sep 18, 2003
Posts: 48
Oh! how could i miss that!!! I guess, i've studied alot and its time for me to sleep. Tomorrow is the BIG day :-)
allison craig
Greenhorn

Joined: Dec 19, 2003
Posts: 17
Your exam is tomorrow? Good luck Geeta!
geeta rai
Ranch Hand

Joined: Sep 18, 2003
Posts: 48
Thanks Allison
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Boolean comparison
 
Similar Threads
a doubt....
Boxing - Boolean question
errata or ??
regarding Wrapper's unboxing
why(boolean b3=true;)(Boolean b4=true;)is both right?