Wiki Markup |
---|
A boxing conversion converts the value of a primitive type to the corresponding value of the reference type, for example, from {{int}} to {{Integer}} \[[JLS 2005, Section 5.1.7|http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#5.1.7], "Boxing Conversions"|AA. Bibliography#JLS 05]\]. This is convenient in cases where an object parameter is required, such as with collection classes like {{Map}} and {{List}}. Another use case is for interoperation with methods that require thiertheir parameters to be object references rather than primitive types. Automatic conversion to the resulting wrapper types also reduces clutter in code. |
...
Objects removed from a collection should always must share the type of the elements of the collection. Numeric promotion and autoboxing can produce unexpected object types. This compliant solution uses an explicit cast to short
that parallels the intended boxed type.
...
Wiki Markup |
---|
\[[Core Java 2004|AA. Bibliography#Core Java 04]\] Chapter 5 \[[JLS 2005|AA. Bibliography#JLS 05]\] [Section 5.1.7, "Boxing Conversions" |http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#5.1.7] \[[Techtalk 2007|AA. Bibliography#Techtalk 07]\] "The Joy of Sets" |
...