Online Tutorials & Training Materials | STechies.com
Register Login

JAVA 8 Introduction and Features

|| || 0

JAVA 8 Introduction and Features
Stechies

This tutorial gives a short introduction about most awaited and most important feature in Java 8.

JAVA 8 is one of the most important releases of Java Programming language. It was initially released on 18 March 2016. It has many major changes to the java Programming language and also added some new important features.

New Features of JAVA 8

1) Lambda Expression:

Lambda expression helps to pass the functionality as an argument to another method for example: d -> d.getAge()>30

2) Default Method

This is non-abstract method introduced by Java 8 which are declared inside the interfaces.

Example:

interface Vehicle{
public void fast();
default int getPrice(){
return 0;
}

3) Method References

In Java 8 we can pass a reference of a method to another.This help in to pass behaviour of instances as the data to the code.

For example validate ( p::getAge );

4) Java Stream API

It helps to process a large amount of data in a parallel stream. Java streams help to write code in a declarative way which keeps the code simple and efficient.

5) Functional Interface

This is an annotation which is introduced to  declare a method with only one abstract method.

For Example:

@FunctionalInterface
interface Addition{
public int add(int a, int b);
}

6) Optional Class

Optional Class is introduced to handle the runtime exceptions.

7) Date Time API

It is an improved version of date time API

8) JavaScript Engine

It is a Java based engine which is used to execute JavaScript code.


Related Articles