0% found this document useful (0 votes)
2K views3 pages

JAVATPOINT--JAVA 8-FEATUR

Java 8, released on March 18, 2014, introduced significant enhancements to the Java programming language, including lambda expressions, method references, and the Stream API. New features such as the Optional class and default methods in interfaces improve code efficiency and readability. Additionally, Java 8 includes a new Date/Time API and the Nashorn JavaScript engine for executing JavaScript code within the JVM.

Uploaded by

Bl Gocher
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views3 pages

JAVATPOINT--JAVA 8-FEATUR

Java 8, released on March 18, 2014, introduced significant enhancements to the Java programming language, including lambda expressions, method references, and the Stream API. New features such as the Optional class and default methods in interfaces improve code efficiency and readability. Additionally, Java 8 includes a new Date/Time API and the Nashorn JavaScript engine for executing JavaScript code within the JVM.

Uploaded by

Bl Gocher
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Java 8 Features

Oracle released a new version of Java as Java 8 in March 18, 2014. It was a
revolutionary release of the Java for software development platform. It includes
various upgrades to the Java programming, JVM, Tools and libraries.

Java 8 Programming Language Enhancements

Java 8 provides following features for Java Programming:

Lambda expressions,
Method references,
Functional interfaces,
Stream API,
Default methods,
Base64 Encode Decode,
Static methods in interface,
Optional class,
Collectors class,
ForEach() method,
Parallel array sorting,
Nashorn JavaScript Engine,
Parallel Array Sorting,
Type and Repating Annotations,
IO Enhancements,

1 Lambda Expressions

Lambda expression helps us to write our code in functional style. It provides a


clear and concise way to implement SAM interface(Single Abstract Method) by using
an expression. It is very useful in collection library in which it helps to
iterate, filter and extract data.

For more information and examples: check offline saved pages

2 Method References

Java 8 Method reference is used to refer method of functional interface . It is


compact and easy form of lambda expression. Each time when you are using lambda
expression to just referring a method, you can replace your lambda expression with
method reference.

Concurrency Enhancements,

JDBC Enhancements etc.

3-Functional Interface

An Interface that contains only one abstract method is known as functional


interface. It can have any number of default and static methods. It can also
declare methods of object class.
Functional interfaces are also known as Single Abstract Method Interfaces (SAM
Interfaces).

For more information and examples:

4 Optional

Java introduced a new class Optional in Java 8. It is a public final class which is
used to deal with NullPointerException in Java application. We must import
java.util package to use this class. It provides methods to check the presence of
value for particular variable.

5 forEach

Java provides a new method forEach() to iterate the elements. It is defined in


Iterable and Stream interfaces.

It is a default method defined in the Iterable interface. Collection classes which


extends Iterable interface can use forEach() method to iterate elements.

This method takes a single parameter which is a functional interface. So, you can
pass lambda expression as an argument.

6 Date/Time API

Java has introduced a new Date and Time API since Java 8. The java.time package
contains Java 8 Date and Time classes.

7 Default Methods

Java provides a facility to create default methods inside the interface. Methods
which are defined inside the interface and tagged with default keyword are known as
default methods. These methods are non-abstract methods and can have method body.

8 Nashorn JavaScript Engine

Nashorn is a JavaScript engine. It is used to execute JavaScript code dynamically


at JVM (Java Virtual Machine). Java provides a command-line tool jjs which is used
to execute JavaScript code.

You can execute JavaScript code by two ways:

Using jjs command-line tool, and


By embedding into Java source code.

9 StringJoiner

Java added a new final class StringJoiner in java.util package. It is used to


construct a sequence of characters separated by a delimiter. Now, you can create
string by passing delimiters like comma(,), hyphen(-) etc.
10 Collectors

Collectors is a final class that extends Object class. It provides reduction


operations, such as accumulating elements into collections, summarizing elements
according to various criteria etc.

11 Stream API

Java 8 java.util.stream package consists of classes, interfaces and an enum to


allow functional-style operations on the elements. It performs lazy computation.
So, it executes only when it requires.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy