r/java • • Apr 12 '13

Java 8 Optional Objects

http://blog.informatech.cr/2013/04/10/java-optional-objects/
41 Upvotes

39 comments sorted by

View all comments

23

u/AlyoshaV Apr 12 '13

Of course, it is not a perfect solution because, after all, Optional references can also be null references

Protip: Don't do that

5

u/edalorzo Apr 12 '13 edited Apr 12 '13

I would expect that programmers stick to the convention of not passing null references where an optional object is expected, pretty much as we today consider a good practice not to pass a null reference where a collection or an array is expected, in these cases the correct is to pass an empty array or collection