Dereferencing a null value leads to a NullPointerException.

An expression may be implicitly dereferenced if its type is a boxed primitive type, and it occurs in a context in which implicit unboxing occurs.

Ensure that the expression does not have a null value when it is dereferenced. Use boxed types as appropriate to hold values that are potentially null.

In the following example implicit unboxing can cause a NullPointerException if helper is null.

If the method is intended to return null, the return type should be changed to Integer.

  • The Java Tutorials: Autoboxing and Unboxing.