Introducing Java 8 Stream API

The Stream API is a new addition to the Collections API in Java 8. The Stream API brings new ways to process collections of objects. A stream represents a sequence of elements and supports different kinds of operations (filter, sort, map, and collect) from a collection. We can chain these operations together to form a pipeline to query the data, as shown in this diagram:

We can obtain a Stream from a collection using the .stream() method. For example, we have a dropdown of languages supported by the sample web application displayed in the header section. Let's capture this in an Array list, as follows:

List<String> ...

Get Selenium WebDriver 3 Practical Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.