This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Inquisition question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Inquisition question " Watch "Inquisition question " New topic
Author

Inquisition question

Daniel Martins
Ranch Hand

Joined: Oct 22, 2009
Posts: 45


This prints false true false

I cannot understand why the 3rs one is false??

2000 == 2000 shouldn't this be true?
Anbarasu Aladiyan
Ranch Hand

Joined: Jun 02, 2009
Posts: 182

Hi Daniel Martins,

This is because of Integer keeps a pool.
Comparing Integer values form -128 to 127 will give result true.
Because at the time of creation no new object is created if the value lies between the range.
Else results false (as usual behavior).


A.A.Anbarasu
Kamil Wojcik
Ranch Hand

Joined: May 19, 2008
Posts: 78

We've been talking a lot about it. You can use Search option or click HERE


SCJP 6.0 Passed | SCWCD Passed | PSM in progress...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inquisition question
 
Similar Threads
Please explain the answers...
query in answer
Integer == Integer?
Q on Integer()
Why it is false?