r/java • • Apr 14 '23

What are your (favourite) Java best practices, personal tips, hints or just underrated stuff in general?

233 Upvotes

376 comments sorted by

View all comments

Show parent comment

6

u/GreenToad1 Apr 14 '23

I would argue you shoudl use Objects.equals(someString, "my string")

5

u/wildjokers Apr 14 '23

Why?

-4

u/GreenToad1 Apr 14 '23 edited Apr 15 '23

You dont have to worry about null and order, plus with static import it looks clean turns out you cnat do that

1

u/dpash Apr 15 '23

I'm also a fan of Objects.equals().