The statement a.b = c
will throw a NullPointerException in the following instances:
- When
a
is null. - If
b
is a primitive type (for example, int) andc
is a type that can be autoboxed (unboxed in this case) to become that primitive type (for example, Integer) andc
is null. - If there is an aop point cut that triggers and something in the point cut throws a NullPointerException.
The statement a.b = c
will never throw a NullPointerException in the following instances:
b
is null.c
is null and there is no autoboxing.