This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
You will find that the other wrapper classes exhibit this caching behaviour for some subrange of their values. However, there are special methods which can be used to ensure that you do get a unique object so check the API.
Originally posted by Roel De Nijs: this is something for Tiger, i guess because my compiler gives an error on the println-statement
Yes - the title Boxing/Unboxing indicates that - it is a Java 5.0 feature. By the way the Tiger is now dead - it's officially released as Java 5.0. [ October 20, 2005: Message edited by: Barry Gaunt ]
Because the documentation says that new Boolean(boolean) creates a new instance.
Then b is a new instance (Boolean b=new Boolean(true) ;) And b2 when it's boxed is the cached instance...
Why the new instance is equal to the cached one?
A lot of thanks in advance. [ October 20, 2005: Message edited by: Barry Gaunt ]
Joined: Aug 03, 2002
There is also the possibility that there is unboxing taking place here. Then the comparison is on two primitives.
Boxing or Unboxing that is the question? Better check this out...
Yes! Section 15.21.2 of the Java Language Specification states that if one of the operands is of type boolean and the other of type Boolean, then it is a boolean equality operation. The Boolean operand is subjected to unboxing. That's why you are getting true for the == operation. [ October 20, 2005: Message edited by: Barry Gaunt ]
Joined: Oct 12, 2005
A lot of thanks.
Joined: Aug 18, 2005
Originally posted by Barry Gaunt: By the way the Tiger is now dead - it's officially released as Java 5.0.
what's that supposed to mean? the people on java.sun.com still refer to j2se 5.0 as tiger
Joined: Aug 03, 2002
Response to off topic post: Yes, they still refer to it as Tiger, but tiger is an internal code name, see codenames. It is normal for the code name to be dropped after the official release. So yes, Tiger is still used, but J2SE 5.0 is the official name. If you want to be cool you must talk about Mustang now, Tiggers are old hat.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com