From the course: Learning Java Enterprise Edition

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Java 8 and Java EE 7 in practice

Java 8 and Java EE 7 in practice - Java EE Tutorial

From the course: Learning Java Enterprise Edition

Start my 1-month free trial

Java 8 and Java EE 7 in practice

- [Instructor] In this video, we will see how to use some of the simplest features of the Stream API, such as map, filter, collect and peek, how to use a function interface and method references, and how parallel streams can process data in a much quicker fashion. Before we start, we need to change the version of Java we have specified in the Maven POM. Open up the POM and scroll down to where we have specified the language source, and change from 1.7 to 1.8. We're going to revisit the default booking service facade class and see if there is not something we can do to refactor it into Java 8 code. If you have a look at the listAllCargos method, we can see that it uses a looped iterator over a collection and to create a DTO from the cargo object. This combination of iteration and object creation presents a good opportunity to try out some Java 8 code. The first thing we can do is to use a new forEach method to iterate over the collections, and for each element it encounters, execute…

Contents