Purpose of Objects.isNull (...) / Objects.nonNull (...)
2 answers
Apart from its obvious use in the functional world. It can also be used in your normal code instead of ==
.
Many programmers (myself included) believe that they are ( x == null
or x != null
) not object oriented , and therefore it makes sense to use the object oriented version.
Java doc objects:
This class consists of static utility methods for working with objects. These utilities include null and invalid methods for calculating the hash code of an object, returning a string for the object, and comparing two objects.
I personally prefer the method version and have been using it for the last couple of years :)
0
source to share