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 Boxing Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Boxing Query" Watch "Boxing Query" New topic

Boxing Query

narain ashwin
Ranch Hand

Joined: Dec 27, 2007
Posts: 48
Was working out boxing concepts from KB book @ page 245, found something strange

it seems upto 127 ( to be precise in the byte range i.e -128 to 127 ) JVM uses the same object for subsequent assignments, whereas from 128 it creates different objects. Any generalization explanation?

I drink two cappuccinos a day.Is that of any help to solve java problems??
JBoss 6 - Admin console Username/pwd: admin/admin
Ankit Garg

Joined: Aug 03, 2008
Posts: 9291

There have been discussions in the past about this like here and here...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
It is sorta covered in the JavaRanch Style Guide.
subject: Boxing Query
Similar Threads
Integer Class
Strange Behaviour Of Wrapper Class
Need help for Autboxing..
Strange Behaviour Of Wrapper Class
Integer unboxing and == operator question