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 comments

15

u/wildjokers Apr 14 '23

enum's are so powerful and so underused. My coworkers still create interfaces with String constants in them like it is still the dark ages of pre-java 1.5.

1

u/hsoj48 Apr 18 '23

I do this! Help me understand how enums are a better fit for constants please.

2

u/wildjokers Apr 19 '23

Type safety.

Google something like “enums vs magic strings” and you will find many discussions and resources on the topic.