September 2019
Intermediate to advanced
816 pages
18h 47m
English
Independent of functional style or imperative code, checking null references is a common and recommended technique used for mitigating the occurrence of famous NullPointerException exception. This kind of checking is heavily exploited for method arguments to ensure that the passing references will not cause NullPointerException or unexpected behavior.
For example, passing List<Integer> to a method may require at least two null checks. First, the method should ensure that the list reference itself is not null. Second, depending on how the list is used, the method should ensure that the list does not contain null objects:
List<Integer> numbers = Arrays.asList(1, 2, null, ...