O'Reilly logo

Java 9 Concurrency Cookbook - Second Edition by Javier Fernández González

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required