O'Reilly logo
  • You Wang thinks this is interesting:

To guard against the possibility that name or hireDay are null, use the Objects.equals method. The call Objects.equals(a, b) returns true if both arguments are null, false if only one is null, and calls a.equals(b) otherwise. With that method, the last statement of the Employee.equals method becomes


Cover of Core Java® Volume I—Fundamentals, Tenth Edition


use "Objects.equals()" to simplify the comparison.