Java 8 brought us one of the most dramatic improvements in terms of coding alternatives for the Java developers: the Streams and Lambdas. Since then, most projects started being deployed on Java version 8 or later, but many developers got stuck in the imperative programming style they were so comfortable with. The truth is that mastering the Functional Programming (FP) style requires determined efforts over quite a while, and it's typically one of the highest leaps a developer has to take while working on production code.
In this 2 hours course, you’ll be introduced to lambda expressions, method references, and the essential parts of Java Streams API. This is a code-driven course for the Java programmer who wants real hands-on experience working with FP. By the end of this course, you’ll have a good understanding of why the new functional capabilities were introduced in Java 8, how FP works within data pipelines, and how this FP style promotes concise, clean, and easier to change code .
- Single Abstract Method (SAM) Functional Interfaces
- Lambda Expressions and Method References
- java.util.function interfaces: Consumers, Suppliers, Functions, Predicates, Operators
- Stream: filter, map, peek, distinct, sorted, *match
- Lazy evaluation and short-circuiting
- Effectively Immutable and the Java Memory Model
- Numeric Streams
Collectors: toList, toSet, toMap, groupingBy, cascading collectors, reduce; pitfalls
What you'll learn
By the end of this hands-on training, you will:
- Have a clear picture of the new functional features available since Java 8 and beyond
- Be able to replace iterations with transformations with filter and map
- Master the lambda expressions and method reference syntax
- Know how to work with the Optional data type
- Understand how the Stream model works under the hood
- Know how to use collectors and comparators
What to expect?
During the training we solve together a series of exercises using the Java 8+ FP features, discussing coding style and tradeoffs while looking for the best implementation alternative.
This Training is for you because:
- You are a Java developer or student with experience in Java 7 or earlier
- Your team started using Java 8 or later for a while but you aren't yet comfortable with Streams and Lambdas
- You want to simplify your code using the functional techniques in Java
- Some practical experience with Java.
- Contact with Java 8 features is a plus, but not required.
To solve the exercises yourself, you will need a Java 8+ SDK installed (latest Oracle JDK will do), a decent IDE (preferably IntelliJ Community), and access to GitHub and Maven Central.
If you want to get the best value out of this workshop, you can prepare by walking through this brief intro or through the official documentation, but the best way is to try to solve in advance the assignment included in the course resources.