Hello friends, lets have a small recap from the last post about “Collections”.
The Collection Interface
What is Collection?
Collection is an interface. The Collection interface is used to manipulate collections of objects.
Collections of objects can be in the form of List, Set , Array etc.
list = new
The Collection interface also exposes methods Stream
stream() and Stream
parallelStream(), for obtaining sequential or parallel streams from the
How can we traverse collections?
There are three ways to traverse collections:
(1) using aggregate operations
(2) with the for-each construct and
We obtain obtain a stream of objects from collection and perform aggregate operations on it.
Obtain a stream as shown below:
items = new ArrayList ();
stream = items.stream();