Shouldn't Optional be Serializable?

Remi Forax forax at
Sat Sep 21 10:31:48 PDT 2013

On 09/20/2013 09:46 PM, Martin Buchholz wrote:
> Both Collections.emptyList and Collections.singleton are serializable.
> I think of Optional as a zero-or-one collection, so it should be 
> serializable too.

Hi Martin,
if Optional is a zero-or-one collection, it should implements 
Collection, it doesn't.
Optional is the result of a computation that can be something or none.

If you want to see Optional as a collection of zero-or-one element,
I think it's better to have a method asSet like Guava.


More information about the jdk8-dev mailing list