Compare two objects with a check for null August 16, 2023 by Tarik Java 7.0 added a new handy class: Objects. It has a method exactly for this: Objects.equals(Object a, Object b)