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 Autoboxing and == operator 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 "Autoboxing and == operator" Watch "Autoboxing and == operator" New topic

Autoboxing and == operator

Arkadiusz Przechodzki

Joined: Sep 04, 2007
Posts: 5

Output: no yes

marc weber

Joined: Aug 31, 2004
Posts: 11343

JLS - 5.1.7 Boxing Conversion...
If the value p being boxed is true, false, a byte, a char in the range \u0000 to \u007f, or an int or short number between -128 and 127, then let r1 and r2 be the results of any two boxing conversions of p. It is always the case that r1 == r2.

Note that the above applies only to boxed values. Creating wrapper instances with "new" is different.

(Also, for the benefit of all users, please use real words instead of text abbreviations. Thanks!)

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
I agree. Here's the link:
subject: Autoboxing and == operator
It's not a secret anymore!