Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
vanjajaja1
on March 13, 2023
|
parent
|
context
|
favorite
| on:
Overhead of Returning Optional Values in Java and ...
That's because Optional.of(null) == Optional.empty() Optional.empty() is boxed null
conro1108
on March 14, 2023
[–]
Optional.of(null) throws a NullPointerException ;)
Optional.ofNullable(null) == Optional.empty()
vanjajaja1
on March 14, 2023
|
parent
[–]
I'm trying to say that .of(null) and .empty() semantically the same, which is why it throws NPE to force explicit empty. ofNullable is a whole other kettle of fish.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: