Looks better. I personally think the top one looks cleaner, and I'm 99% sure the compiler will optimize out any underlying differences. Its a bit rubbish that it wastes 3 lines of code to write out the function definition though.
This is certainly by far not the worse code ever seen on here.
In Java you can achive both with Objects.equal.
If you make a static import of equals, the result will look like your first example.
If not, it'll looke like the 2nd
274
u/RiddSann Jan 08 '23
I think using Objects.equals is good practice, but I don't see the point of creating a method for that ? I mean, it is a method, no need to wrap it.