I was writing code, when IntelliJ suggested me a correction on:
objectOne.equals(objectTwo);
telling me that the Method invocation equals may produce the good old java.lang.NullPointerException , proposing as solution something that I wasn't aware of, Objects.equals:
Objects.equals(objectOne, objectTwo);
Reading the documentation I see only one potential problem, which is that if objectOne == null and objectTwo == null , then the result is true.
At this point the question is: could I start replacing and using everywhere this method instead of .equals ?
Is this a safe approach or I'm missing some big contraindication?
Getting rid of NPE is very attractive... Thanks