MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/java/comments/12lmj78/what_are_your_favourite_java_best_practices/jg8my9w
r/java • u/trecatorsirabdator • Apr 14 '23
376 comments sorted by
View all comments
Show parent comments
3
Because you can pass null in for the value of the Optional parameter. You have gained nothing.
null
7 u/Fruloops Apr 14 '23 Not at all. You've gained hours of potential frustration. That should not be underestimated. 1 u/ArrozConmigo Apr 14 '23 That's a pretty unlikely mistake to make, and it will throw an NPE the first (and every) time it runs. If you accidentally pass null for an Optional, you didn't do it conditionally. You'd be doing it every time.
7
Not at all. You've gained hours of potential frustration. That should not be underestimated.
1
That's a pretty unlikely mistake to make, and it will throw an NPE the first (and every) time it runs. If you accidentally pass null for an Optional, you didn't do it conditionally. You'd be doing it every time.
3
u/wildjokers Apr 14 '23
Because you can pass
nullin for the value of the Optional parameter. You have gained nothing.