October 2018
Intermediate to advanced
592 pages
19h 49m
English
This chapter covers
In the previous chapter, you saw that streams let you move from external iteration to internal iteration. Instead of writing code, as follows, where you explicitly manage the iteration over a collection of data (external iteration),
List<Dish> vegetarianDishes = new ArrayList<>();
for(Dish d: menu) {
if(d.isVegetarian()){
vegetarianDishes.add(d);
}
}
you can use the Streams API (internal iteration), which supports the filter and collect operations, to manage the iteration over the collection of data for you. All ...