This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori 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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 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...
I agree. Here's the link:
subject: Inquisition question
It's not a secret anymore!