Return types array/list/stream [was: API question for point lambdafication]

Stephen Colebourne scolebourne at
Wed Feb 20 09:22:26 PST 2013

On 20 February 2013 16:54, Patrick Wright <pdoubleya at> wrote:
>> think, like all new features, there is a danger of over-use. Laying
>> down some guidelines on usage is a Good Thing IMO. Stream really
>> shouldn't be the default return type - List is frequently much more
>> useful to clients.
> For the record, can you tell us exactly why (perhaps with code examples) you
> feel that "list is...more useful to clients?"

Asides from having a working toString, hashCode, equals, it has many
other methods that allow practical manipulation by developers, such as
indexOf, lastIndexOf, contains or subList. It can also be passed on to
other methods (which you may not have written) that expect a list.
While all of these things can be achieved using an array, they are
frequently a pain to read.

I don't recall writing code returning an array publicly in a long
time. If I reviewed any code from someone doing it I'd want a very
good justification for using an array.


More information about the lambda-dev mailing list