Optional used as method argument?

Wang Weijun weijun.wang at oracle.com
Fri Oct 2 01:25:43 UTC 2015


I hear people saying Optional is usually used as return values. Can I use it as an argument, like this?

  void consume(Optional<String> value)

This way, I don't need to add spec like "@param value can be null if there is no such value".

Thanks
Max




More information about the core-libs-dev mailing list