

Instead concerned with declaratively describing their source and theĬomputational operations which will be performed in aggregate on that source. Provide a means to directly access or manipulate their elements, and are Management of, and access to, their elements. Collections are primarily concerned with the efficient Terminal operation is initiated, and source elements are consumed onlyĬollections and streams, while bearing some superficial similarities, Streams are lazy computation on the source data is only performed when the Terminal operation (which produces a result or side-effect, such Stream into another stream, such as filter(Predicate)), and a Might be an array, a collection, a generator function, an I/O channel,Įtc), zero or more intermediate operations (which transform a A stream pipeline consists of a source (which There are primitive specializations for IntStream, LongStream,Īnd DoubleStream, all of which are referred to as "streams" andĬonform to the characteristics and restrictions described here. In addition to Stream, which is a stream of object references, Then this stream is summed to produce a total weight. Transform it into a stream of int values representing the weight ofĮach red widget. We createĪ stream of Widget objects via Collection.stream(),įilter it to produce a stream containing only the red widgets, and then In this example, widgets is a Collection. The following example illustrates an aggregate operation using

A sequence of elements supporting sequential and parallel aggregate
