This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one 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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Inquisition question " Watch "Inquisition question " New topic

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).

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...
Consider Paul's rocket mass heater.
subject: Inquisition question