Follow these steps to implement the example:
- First, let's implement some auxiliary classes we will use in the example. Implement the Person class to store some basic data about a person and the PersonGenerator class to generate a random list of persons. You can check the Creating streams from different sources recipe to see the source code of both the classes.
- In that class, override the toString() method with the following code, which returns the first name and the last name of the person:
@Override public String toString() { return firstName + " " + lastName; }
- Then, create a class named Counter with two attributes: a String attribute named value and an int attribute named counter. Generate the methods to get()