Wrapper reference variables can be null : Boxing Unboxing « Utility Classes « SCJP






public class MainClass{
      static Integer x;
      public static void main(String [] args) {
        doStuff(x);
      }
      static void doStuff(int z) {
        int z2 = 5;
        System.out.println(z2 + z);
      } 
    }

x doesnt refer to an Integer object, so theres no value to unbox.








8.10.Boxing Unboxing
8.10.1.Rules for overloading methods using widening, boxing, and var-args
8.10.2.Boxing, ==, and equals()
8.10.3.Where Boxing Can Be Used
8.10.4.Wrapper reference variables can be null
8.10.5.Overloading Method Matching
8.10.6.Overloading with Boxing and Var-args
8.10.7.Predict the output of the following
8.10.8.boxing beat var-args
8.10.9.Overloading When Combining Widening and Boxing
8.10.10.A boxing operation followed by a widening operation in order to match an invocation to a method.
8.10.11.Overloading in Combination with Var-args
8.10.12.Autoboxing and auto-unboxing are compiler modifications that permit previously illegal combinations of wrappers and primitives.
8.10.13.The wrapper on the left-hand side must correspond exactly to the primitive type on the right-hand side.
8.10.14.The following autoboxing assignment is illegal
8.10.15.Boxing requires an exact match between the wrapper class and the primitive type.
8.10.16.Boxing also occurs when a method's return type is a wrapper.
8.10.17.Unboxing is the automatic extraction of a wrapped value.
8.10.18.Unboxing the parameter