Skip to main content
added 10 characters in body
Source Link
Mark Rotteveel
  • 106.7k
  • 215
  • 149
  • 206

Since Java 7 you can use the static method java.util.Objects.equals(Object, Object) to perform equals checks on two objects without caring about them being null.

If both objects are null it will return true, if one is null and another isn't it will return false. Otherwise it will return the result of calling equals on the first object with the second as argument.

Since Java 7 you can use the static method Objects.equals(Object, Object) to perform equals checks on two objects without caring about them being null.

If both objects are null it will return true, if one is null and another isn't it will return false. Otherwise it will return the result of calling equals on the first object with the second as argument.

Since Java 7 you can use the static method java.util.Objects.equals(Object, Object) to perform equals checks on two objects without caring about them being null.

If both objects are null it will return true, if one is null and another isn't it will return false. Otherwise it will return the result of calling equals on the first object with the second as argument.

added 110 characters in body
Source Link
Jens Piegsa
  • 7.5k
  • 6
  • 60
  • 108

If you useSince Java 7 you can use the static method Objects.equals(Object, Object) to perform equals checks on two objects without caring about them being nullnull. 

If both objects are null it will return true, if one is nullnull and another isn't it will return false. Otherwise it will return the result of calling equalsequals on the first object with the second as argument.

If you use Java 7 you can use the static method Objects.equals(Object, Object) to perform equals checks on two objects without caring about them being null. If both objects are null it will return true, if one is null and another isn't it will return false. Otherwise it will return the result of calling equals on the first object with the second as argument

Since Java 7 you can use the static method Objects.equals(Object, Object) to perform equals checks on two objects without caring about them being null. 

If both objects are null it will return true, if one is null and another isn't it will return false. Otherwise it will return the result of calling equals on the first object with the second as argument.

Source Link
Mark Rotteveel
  • 106.7k
  • 215
  • 149
  • 206

If you use Java 7 you can use the static method Objects.equals(Object, Object) to perform equals checks on two objects without caring about them being null. If both objects are null it will return true, if one is null and another isn't it will return false. Otherwise it will return the result of calling equals on the first object with the second as argument