17.6 Stream<Employee> Manipulations

The example in Figs. 17.917.16 demonstrates various lambda and stream capabilities using a Stream<Employee>. Class Employee (Fig. 17.9) represents an employee with a first name, last name, salary and department and provides methods for manipulating these values. In addition, the class provides a getName method (lines 69–72) that returns the combined first and last name as a String, and a toString method (lines 75–80) that returns a formatted String containing the employee’s first name, last name, salary and department.

 1   // Fig. 17.9: Employee.java 2   // Employee class. 3   public class Employee 4   { 5      private String firstName; 6      private String lastName; 7       ...

Get Java™ How To Program (Early Objects), Tenth 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.