Objects.equals and Object.equals
The difference is the Objects.equals()
considers two nulls to be "equal". The pseudo code is:
- if both parameters are
null
or the same object, returntrue
- if the first parameter is
null
returnfalse
- return the result of passing the second parameter to the
equals()
method of the first parameter
This means it is "null safe" (non null safe implementation of the first parameter’s equals()
method notwithstanding).
this is literal code from java source: as you can see, @Agent_L is right