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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.