Java 8 introduced a wealth of new features, pushing Java towards the so-called functional programming paradigm. Benefits from this shift include succinctness and ease of developing robust multi-threaded applications.
In this course, we will introduce the key functional features of Java 8 and 9, and explain how they can be used to write code that is more expressive and easily amenable to parallelization.
Specifically, we will first discuss lambda functions and functional interfaces. Using these features, programmers can easily create objects that offer a single specific service, similarly to anonymous classes. We will also explore the predefined functional interfaces that can be found in the Java API, starting from well-known pre-existing ones like Comparator and Runnable.
Reaping the full benefits of lambda functions requires employing them with streams, a new kind of collection with built-in parallelization support. We will examine the relationship between streams and collections, and how the latter have changed as a result of the new language features.
Finally, after having mastered the key features of streams, we will consider the details related to parallel execution, such as the crucial notion of side-effect and the fork-join execution model.
About the Author :
Marco Faella is a professor of Computer Science at the University of Naples “Federico II”, Italy. He has taught classes on Java programming, compiler construction, and software engineering to undergraduate and graduate students since 2005. He is the author of over 50 scientific publications in international conferences and journals. He has also developed scientific software in C++, OCaml, Python, and Java.
Marco is fluent in C, C++, OCaml, Python, and Java and has contributed to the Parma Polyhedra Library, a well-known scientific library for symbolic manipulation of polyhedra.
He has an extensive teaching experience in related topics, specifically a course on advanced Java programming with generics, collections, and multi-threading, which he has been teaching for the last 10 years (Linguaggi di Programmazione 2). He’s also writing 4 chapters of an upcoming book (in Italian) on Oracle OCP Java certification.
What are the functional interfaces that were already present in Java 7? Can they be used as targets of lambda expressions?
How can I terminate a stream? How can I summarize a stream into a single object?
How do 2-dimensional games detect collisions between game objects? How can we exploit functional-style programming to improve the performance of collision detection algorithms?
How can we further speed up collision detection? How can we build a stream of collisions from a stream of shapes?Is it beneficial to turn every stream into a parallel stream?
Packt has been committed to developer learning since 2004. A lot has changed in software since then - but Packt has remained responsive to these changes, continuing to look forward at the trends and tools defining the way we work and live. And how to put them to work.
With an extensive library of content - more than 4000 books and video courses -Packt's mission is to help developers stay relevant in a rapidly changing world. From new web frameworks and programming languages, to cutting edge data analytics, and DevOps, Packt takes software professionals in every field to what's important to them now.
From skills that will help you to develop and future proof your career to immediate solutions to every day tech challenges, Packt is a go-to resource to make you a better, smarter developer.
Packt Udemy courses continue this tradition, bringing you comprehensive yet concise video courses straight from the experts.