Checks that the specified object reference is not null
. This
method is designed primarily for doing parameter validation in methods
and constructors, as demonstrated below:
public Foo(Bar bar) { this.bar = Objects.requireNonNull(bar); }
obj | the object reference to check for nullity | |
<T> | the type of the reference |
obj
if not null
NullPointerException | if obj is null |
Diagram: Object