File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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!