This article provides a summary of the important Java 8 new features.
Java 8 new features
Java 8 is the newest release of Java and the developer kit is JDK 8.
This is a significant upgrade to Java language.
1. Lambda Expressions
Lambda expression is a major change in java as it changes how code is written in java and how solutions are conceptualized.
A lambda expression is a method without a name, access-specifier or return value declaration.
Lambda expressions add functional programming features to java. This simplifies and greatly reduces the amount of code written to achieve tasks.
You may refer following article for more details on Lambda expressions :
2. Functional Interface
A functional interface is an interface that contains only one abstract method. Then main advantage of it is that it can be used to refer to a lambda expression.
You may refer following article for more details on Functional Interfaces :
3. New Stream API
Stream represents a flow of objects on which operations can be performed. Primary aim of streams is to make the operations easy on collections.
The newly added Stream api is available in java.util.Stream package for creating and working with Streams.
It supports pipeline operations on data and is optimized for Lambda expressions.
Click on below links to read more about Java8 Streams:
4 New java.util.function package
This new package defines number of functional interfaces that provide additional support for lambda expressions.
Predicates and Functions
A predicate is a function with a single argument that returns a boolean value.
Functions are similar to Predicates, but functions return an object as a result.
Both predicates and functions are useful to evaluate lambda expressions.
5. Interface default methods
Traditionally, interfaces contain only constants and method signatures. They cannot contain method implementations.
Beginning JDK 8, it is possible to define default implementation for a method in an interface. These methods are called default methods.
A default method is declared using a keyword “default” and it contains a method body.
A default method is available to all implementing classes of the interface. If the implementation class wants to use it, it can use it or it can ignore the default implementation and create its own implementation.
You may refer following article for more details on default interface methods :
6. New Date Time api
JDK 8 added a new Date time api. Read more about it in below article :
© 2015 – 2018, https:. All rights reserved. On republishing this post, you must provide link to original post