MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/java/comments/12lmj78/what_are_your_favourite_java_best_practices/jg7p432
r/java • u/trecatorsirabdator • Apr 14 '23
376 comments sorted by
View all comments
Show parent comments
2
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?
NULL
4 u/john16384 Apr 14 '23 There is OptionalInt. I myself however find returning Integer instead of int sufficient to know whether or not something may be null. 1 u/hippydipster Apr 14 '23 Optional<Integer>
4
There is OptionalInt. I myself however find returning Integer instead of int sufficient to know whether or not something may be null.
OptionalInt
Integer
int
null
1
Optional<Integer>
2
u/[deleted] Apr 14 '23
So how do you represent a
NULLvalue from an integer column in the database in Java?