Basic filtering

The first and the most straightforward way to do filtering is using the filter() operation. To demonstrate all the following capabilities, we will use the Senator class:

public class Senator {    private int[] voteYes, voteNo;    private String name, party;    public Senator(String name, String party,                      int[] voteYes, int[] voteNo) {        this.voteYes = voteYes;        this.voteNo = voteNo;        this.name = name;        this.party = party;    }    public int[] getVoteYes() { return voteYes; }    public int[] getVoteNo() { return voteNo; }    public String getName() { return name; }    public String getParty() { return party; }    public String toString() {        return getName() + ", P" +           getParty().substring(getParty().length() - 1);    }}

As you can see, this class captures a senator's ...

Get Java 9 High Performance 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.