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

Sam Pullara sam at
Wed Feb 20 09:36:38 PST 2013

I'd much rather not have the API allocating a List for me, so put me
firmly in the return a Stream camp.


On Wed, Feb 20, 2013 at 9:22 AM, Stephen Colebourne
<scolebourne at> wrote:
> 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.
> Stephen

More information about the lambda-dev mailing list