A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Spring in Action
this week in the
Programmer Certification (SCJP/OCPJP)
Joined: Jun 12, 2005
Aug 22, 2006 11:15:00
Why the output is
Boolean b1 = new Boolean(true);
Boolean b2 = new Boolean(true);
boolean b3 =true;
Could anybody explain....
Joined: Mar 24, 2006
Aug 22, 2006 11:34:00
I think it is because:
(b1==b2) and (b1==b4) compares two reference variable pointing to two diferent Boolean instances. (true is boxed into b4);
(b1==b3) compares two primitives (b1 is unboxed).
(b3==b4) compares two primitives.
Joined: Feb 02, 2006
Aug 22, 2006 11:37:00
15.21.1 Numerical Equality Operators == and !=
5.6.2 Binary Numeric Promotion
Don't get me started about those stupid
subject: Boxing query
conditional operator precedence
Boxing conversions question
Please explain boxing conversion
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014