The equals() method of StringUtils class is a null-safe version of the equals() method of String class , which also handles null values.
Read moreDoes equals null safe Java?
The equals() method of StringUtils class is a null-safe version of the equals() method of String class , which also handles null values.
Read moreIs equalsIgnoreCase null safe?
equalsIgnoreCase(null); will definitely result in a NullPointerException . So equals methods are not designed to test whether an object is null, just because you can’t invoke them on null .
Read moreCan we use equals with null?
It’s entirely possible for two distinct object instances to be “equal” according to their contract. And then there’s the minor detail that since equals is a method, if you try to invoke it on a null reference, you’ll get a NullPointerException .
Read moreCan you call equals on null?
Consequently, if both arguments are null, it returns true and if exactly one argument is null, it returns false. Otherwise, it then simply calls the equals() method of the passed argument’s type’s class – which in our case is String’s class equals() method.
Read moreCan you do object equals null?
It’s entirely possible for two distinct object instances to be “equal” according to their contract. And then there’s the minor detail that since equals is a method, if you try to invoke it on a null reference, you’ll get a NullPointerException .
Read more