An Overview Between Java 8 and Java 11
This tutorial covers the basics of Java 8 and Java 11; it is a start to prepare you for the next LTS: Java 17.
Join the DZone community and get the full member experience.Join For Free
One of the great news introduced in the Java world is related to the version cycle, of which we have a release every six months and a version of Long Term Support every three years. Currently, the LTS version is Java 11, from which many companies are moving towards its use. First, this movement is significant because new frameworks will not support Java 8 and will consider Java 11 as a minimum beyond the point that the next LTS will be in September 2021 with Java 11. The purpose of this article is to talk a little about the basic APIs that happens between Java 8 and Java 11.
The Functions Classes
An important point that will serve as a basis, starting with Java 8, is the new interfaces within the
java.util.function package, in this overview, we'll see covert four interfaces:
Function: Represents a function that accepts one argument and produces a result:
Predicate: Represents a predicate (boolean-valued function) of one argument.
Supplier: Represents a supplier of results.
Consumer: Represents an operation that accepts a single input argument and returns no result.
On those interfaces, we'll see several improvements, such as in the Collections implementations:
Also, there are new methods factories to make it easier to create the collections interfaces:
Stream is a sequence of elements supporting sequential and parallel aggregate operations. We can think about a waterfall or a river flow. This API is robust and clean to manipulate a collection such as:
When Java 8 was released, a new Date and Time API with new types, immutable classes, practical news methods, and finally Enums to the day of weeks and months instead of numbers.
As the current LTS, Java 11 has several features that make the developer live easier in their day job. This post was only an overview and quickly started with Java 11 and missed some Java 8. There are many references about the feature to each new version.
Opinions expressed by DZone contributors are their own.