Stream has been added in the new API ‘s Java 8 to help you work with collections. Here’s a simple example of how to filter data in a list .
List<Animals> birds = allAnimals.stream().filter(a -> a.isBird()).collect(toList());
public class Animals {
{ ... }
private boolean bird;
public boolean isBird() {
return bird;
}
public void setBird(boolean bird) {
this.bird = bird;
}
{...}
}