Selenium WebDriver Quick Start Guide
上QQ阅读APP看书,第一时间看更新

Streams in Java 8

As per the Java documentation's definition:

Streams are a sequence of elements supporting sequential and parallel aggregate operations.

Imagine a factory in which workers are standing with tools in their hands, and machine parts keep moving around so that the individual worker can do their part. Streams can be compared somewhat to such a scenario:

List<String> fruits = Arrays.asList("Apples","Oranges","Bananas","Pears");
fruits.stream().forEach(fruit -> System.out.println(fruit));