September 2019
Intermediate to advanced
816 pages
18h 47m
English
Of course, one solution entails relying directly on the == operator as follows:
if (name == null) { throw new IllegalArgumentException("Name cannot be null");}
This problem cannot be solved via the methods of java.util.Objects since there is no requireNonNullElseThrow() method. Throwing IllegalArgumentException or another specified exception may require a set of methods, as shown in following screenshot:

Let's focus on the requireNonNullElseThrowIAE() methods. These two methods throw IllegalArgumentException with a custom message specified as String or as Supplier (to avoid ...