Robert

60%
Flag icon
In Java 8, there is a third approach to writing methods that may not be able to return a value. The Optional<T> class represents an immutable container that can hold either a single non-null T reference or nothing at all.
Robert
I'm still not convinced that Optionals is a good thing, that Optionals is something that I want to use. Some of the reasons: • It actually introduces another possibility of failure: if a method returns null instead of an empty optional. • It introduces another object (instantiation/allocation). I'd really love to know why this was chosen over adoption of a syntactic solution or annotations (such as @Nullable).
Effective Java
Rate this book
Clear rating
Open Preview