Java 8 Features
16 lessons in this section of the Java tutorial. Work through them in order, or jump to the one you need.
- 1.Lambda Expressions
Lambda expressions, introduced in Java 8, are anonymous functions — blocks of code that can be stored in variables, passed as arguments, and returned from methods…
- 2.Functional Interfaces
A functional interface is any Java interface that has exactly one abstract method.
- 3.Predicate
Predicate<T> is a functional interface in java.util.function representing a boolean-valued function of one argument, with the single abstract method boolean test(T t).
- 4.Function
Function<T,R> is a functional interface in java.util.function representing a function that accepts one argument of type T and produces a result of type R, with the…
- 5.Consumer
Consumer<T> is a functional interface in java.util.function that represents an operation that accepts a single input argument and returns no result.
- 6.Supplier
Supplier<T> is a functional interface in java.util.function that represents a factory or source of values — it takes no arguments and returns a value of type T.
- 7.Method References
Method references are a shorthand syntax for lambda expressions that simply call an existing method.
- 8.Stream API
The Stream API, introduced in Java 8, provides a functional, declarative model for processing sequences of elements.
- 9.Intermediate Operations
Intermediate operations are Stream API methods that transform one stream into another stream, enabling pipeline construction through method chaining.
- 10.Terminal Operations
Terminal operations are Stream API methods that trigger the actual traversal and processing of a stream pipeline, producing a non-stream result — a value, a collection…
- 11.Optional
Optional<T>, introduced in Java 8, is a container object that may or may not hold a non-null value, designed to make the possible absence of a value explicit in a…
- 12.Default Methods
Default methods, introduced in Java 8, are methods declared in an interface with a body, marked with the default keyword, providing a concrete implementation that…
- 13.Static Interface Methods
Static interface methods, introduced in Java 8 alongside default methods, are methods declared static with a body inside an interface, callable only through the…
- 14.Date Time API
The java.time API (JSR-310), introduced in Java 8, is a complete replacement for the legacy java.util.Date and java.util.Calendar classes, built around immutable…
- 15.Base64
Base64 is a binary-to-text encoding scheme that represents arbitrary byte data using only 64 printable ASCII characters (A–Z, a–z, 0–9, plus two symbols), making binary…
- 16.Parallel Streams
Parallel streams, introduced in Java 8 alongside the Streams API, allow a stream pipeline to split its source data into segments processed concurrently across multiple…