Java 8 new features

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.

Java8 new features

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 :

Java8 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 :

Java8 Functional Interface

 

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:

Java8 Streams
Java 8 Stream Operations with Examples
 

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.

 
Read more about Predicates and Functions
 

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 :

 

Default Interface Method in Java8

 

6. New Date Time api

 
JDK 8 added a new Date time api. Read more about it in below article :

Java 8 Date Time api
 

© 2015 – 2023, https:. All rights reserved. On republishing this post, you must provide link to original post

5 comments

  1. […] Java 8 new features […]

Leave a Reply.. code can be added in <code> </code> tags

%d bloggers like this: