Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That's because Optional.of(null) == Optional.empty() Optional.empty() is boxed null


Optional.of(null) throws a NullPointerException ;)

Optional.ofNullable(null) == Optional.empty()


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: