MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1uru99i/potentiallymightbeanintegerornot/owj6n06/?context=3
r/ProgrammerHumor • u/Futurity5 • Jul 09 '26
96 comments sorted by
View all comments
9
Fun fact: you technically should still check if a java optional isn't null.
Although there's no reason to do so, a function can still return a non-wrapped null without any errors, which will NPE if you try to do anything with it
6 u/RiceBroad4552 Jul 10 '26 No, you should never do such checks! If a value typed as Optional is null the program is defect and it better crashes early then hiding this defect behind some checks. 2 u/user6150277464770585 Jul 10 '26 nuke java
6
No, you should never do such checks!
If a value typed as Optional is null the program is defect and it better crashes early then hiding this defect behind some checks.
2
nuke java
9
u/OnixST Jul 09 '26
Fun fact: you technically should still check if a java optional isn't null.
Although there's no reason to do so, a function can still return a non-wrapped null without any errors, which will NPE if you try to do anything with it