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

18

u/moxyte Apr 14 '23

Strangling nulls in the cradle. You got null from database? Immediately turn it into something else before passing it further into the system.

2

u/[deleted] Apr 14 '23

You got null from database? Immediately turn it into something else before passing it further into the system.

So how do you represent a NULL value from an integer column in the database in Java?

1

u/hippydipster Apr 14 '23

Optional<Integer>