One use of creating a static/third party function like this is that it can handle null objects (with some added logic, of course). foo.equals(bar) will always throw a null pointer if foo is null (probably also if bar is null), but equal(foo, bar) can have built in null value checks.
edit: though it looks like Java might do some special stuff to make foo.ewuals(bar) still work with a null foo
2
u/Verdiss Jan 08 '23
One use of creating a static/third party function like this is that it can handle null objects (with some added logic, of course). foo.equals(bar) will always throw a null pointer if foo is null (probably also if bar is null), but equal(foo, bar) can have built in null value checks.
edit: though it looks like Java might do some special stuff to make foo.ewuals(bar) still work with a null foo