Follow these steps to implement the example:
- First, we'll create some auxiliary classes that we will use later in the example. Review the recipe, Creating streams from different sources, and include in this example the Person and PersonGenerator classes used in it.
- Then, create a class named DoubleGenerator. Implement a method named generateDoubleList() to generate a list of double numbers. It receives two parameters with the size of the list we'll generate and the highest value in the list. It will generate a list of random double numbers:
public class DoubleGenerator { public static List<Double> generateDoubleList(int size, int max) { Random random=new Random(); List<Double> numbers=new ArrayList<>(); for (int i=0; ...