What are the new features introduced in Java 8

  1. Functional interface
  2. Lambda Expression
  3. Stream Api
  4. Date and Time Api
  5. Default and static method inside interface
  6. Base64 encode decode
  7. Optional class
  8. Method and constructor reference(double operator) .. etc.

What is Functional Interface?

Functional Interface was first introduced in jdk 1.8 version. An interface having exactly one abstract method is called Functional Interface. It may have any number of static and default methods with body. Body must be declared for static and default methods for functional interface. We may denote a functional interface with @FunctionalInterface. Some predefined functional interface that introduced in java 1.8 are :

  1. Function functional interface
  2. Predicate
  3. Supplier
  4. Consumer
  5. Bi-Function
  6. Bi-Predicate
  7. Bi-Consumer etc.

Some functional interface before java 1.8 are Runnable, ActionListener, Comparable etc. From Java 8 onwards, Lambda expression is used to represent instance of functional interface. Every variable in functional interface by default is public, static and final.

What is Lambda Expression in Java

In Java 1.8, Lambda expression is introduced.
To implement functional interface, Lambda expression is used. It is also called an anonymous function without any name, return type and without any modifiers. Without the concept of functional interface, Lambda expression can not be invoked.
It is also called an arrow function. With Lambda expression, we can write concised code.

1 thought on “What are the new features introduced in Java 8”

Leave a Comment