This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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


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
 
 
subject: Boolean comparison