Skip to main content
Boxing
- As of Java 5, boxing allows you to convert primitives to wrappers or to convert wrappers to primitives automatically.
- Using == with wrappers created through boxing is tricky; those with the same
- small values (typically lower than 127), will be ==, larger values will not be ==.
- Advanced Overloading (Objectives 1.5 and 5.4)
- Primitive widening uses the "smallest" method argument possible.
- Used individually, boxing and var-args are compatible with overloading.
- You CANNOT widen from one wrapper type to another. (IS-A fails.)
- You CANNOT widen and then box. (An int can't become a Long.)
- You can box and then widen. (An int can become an Object, via an Integer.)
- You can combine var-args with either widening or boxing.