How to do it...

In this recipe we'll implement an example where you will learn how to create streams from the sources described earlier. Follow these steps to implement the example:

  1. First, we'll implement some auxiliary classes that we will use in the example. Create a class named Person with six attributes of different types: String, int, double and Date:
        public class Person implements Comparable<Person> {            private int id;           private String firstName;           private String lastName;           private Date birthDate;           private int salary;           private double coeficient;
  1. Create the methods to set and get the values of these attributes. Implement the comparteTo() method to compare two Person objects. Let's consider that two persons are the same it they have ...

Get Java 9 Concurrency Cookbook - Second Edition 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.