1. Lambda Expressions
● escription: Lambda expressions allow you to write concise and flexible code by
D
providing a way to express instances of single-method interfaces (functional interfaces)
in a more compact form.
● Syntax:(parameters) -> expressionor(parameters)-> { statements }
Example:
2. Functional Interfaces
● escription: A functional interface is an interface with exactly one abstract method. Java
D
8 introduced the@FunctionalInterfaceannotation toensure that an interface meets this
condition.
Example:
3. Streams API
● escription: The Streams API allows you to process sequences of elements (such as
D
collections) in a functional style. It supports operations such as filtering, mapping, and
reducing.
Example:
4. Default Methods
● escription: Interfaces can now have default methods with a body. This allows you to add
D
new methods to interfaces without affecting the classes that implement the interface.
Example:
5. Static Methods in Interfaces
● escription: Java 8 allows interfaces to have static methods. These methods belong to
D
the interface itself, not to instances of classes implementing the interface.
Example:
6. Method References
● escription: Method references provide a way to refer to methods or constructors
D
directly using their names. They can be used to simplify lambda expressions.
● Syntax:ClassName::methodName
Example:
7. Optional Class
● escription: TheOptionalclass is a container objectwhich may or may not contain a
D
value. It is used to avoid null references and to represent the presence or absence of a
value.
Example:
8. New Date and Time API
● escription: Java 8 introduced a new Date and Time API injava.timepackage, which is
D
more comprehensive and user-friendly compared to the oldjava.util.Dateand
java.util.Calendarclasses.
Example:
9. Nashorn JavaScript Engine
● escription: Nashorn is a new JavaScript engine that replaces the older Rhino engine. It
D
provides better performance and compliance with the JavaScript standard.
Example:
10. Parallel Streams
● escription: The Streams API supports parallel processing of data, allowing for
D
concurrent execution of operations on data streams.
Example:
11. CompletableFuture
● escription:CompletableFutureis part of thejava.util.concurrentpackage and provides
D
a way to write asynchronous, non-blocking code. It supports a variety of methods for
combining and managing asynchronous tasks.
Example:
12. New Functional Interfaces in java.util.function
● escription: Java 8 introduced several new functional interfaces in thejava.util.function
D
package, such asFunction,Predicate,Consumer,Supplier,and others, which facilitate
functional programming.
Example: