Skip to main content

Java 8 New Features List

Java SE 8 is released on 18th March 2014 and it is the most powerful release to enable functional programming. Java SE 8 is one of the releases which has numerous totally new features.
In this post, we will have a look at those new features of java 8 in brief. Some other small changes and bug fixes are also available as a part of java 8. Focus the following list of java 8 new features.

  • Lambda Expression
  • Functional Interface
  • Default and static methods inside the interface
  • Predefined functional interfaces(Predicates, Function, Consumer, etc).
  • Double(::) operator
  • Stream API
  • Date & Time API(Joda API)

Main Objectives of Java 8

  • To simplify the way of writing code or to simplify the programming.
  • To utilize the benefits of functional programming using a lambda expression. Remember java 8 is still object-oriented programing language.
  • To enable parallel programming or parallel processing in java.

1. Lambda Expression

Lambda expression is an anonymous function (a nameless function that does not have a modifier, return type, and even the type of its arguments). Java compiler infers the name, type of arguments, and return type from the functional interface method. Lambda expression gives you the power to pass the customize code to your java method. Click here to read more.

2. Functional Interface

The functional interface contains only a single abstract method also known as SAM. For example Runnable, Callable, Comparable, etc. But It can contain any number of default and static methods.
Lambda expression provides the implementation of the functional interface. Click here to read more. 

3. Default and Static methods inside Interface

Before Java 8, we could not define static and default methods inside an interface. But from java 8, we can define n numbers of static and default methods inside the interface. Default methods are declared with the default keyword at the beginning of the method signature and then provide an implementation of the method. Click here to read more.

4. Predefined Functional Interfaces

Java 8 provided a lot of predefined functional interfaces for utilizing the benefits of functional programming using lambda expression and method reference. These interfaces are present inside the package java.util.function and annotated with @FunctionalInterface. Click here to read more.

5. Double (::) Operator

Java 8 double (::) operator knows as method reference, is used for the method or constructor reference.
Java 8 provides four types of method reference (i) static method reference (ii) instance method reference for a specific object (iii) constructor reference (iv) instance method reference for an arbitrary object of a specific type. Click here to read more.

6. Stream API

Java 8 Stream(Interface present inside java.util.stream) is a series of objects which is obtained from the collection or from a group of values. Stream API is used for processing the collection of objects or groups of values efficiently and allows us to execute multiple operations on it. There are a lot of operations that can be performed on the stream for example map, filter, sorted, collect, foreach, etc. Click here to read more.

7. Date & Time API(Joda Time API)

The date & time API has defined several classes and interfaces to handle the date and time effectively. This API also know as Joda Time API(developed by joda.org) and the classes/interfaces of this API are present inside java.time package. Click here to read more.

Thank you so much for reading this post. This is the brief introduction for the java 8 new features and you can read more by using the link given inside every point. Please comment below if there is any query or feedback. I will try to respond back.

Comments

Post a Comment

Popular posts from this blog

How to add an existing project to a GitHub Repository

  Add Existing project to a GitHub Repository Step 1: Login into your GitHub account and create a new repository. Step 2: Go to your project folder on your machine and open git bash. After that runs the command “ git init ”. This command initialized the empty git repository on your local machine. Step 3: Create a file “. gitignore ” using the command “ echo > .gitignore ”. Add the file extension or file name inside this file, those you don’t want to commit to your repository. Git will ignore all those files that will be present inside this file. Step 4: Add all the files to the staging area using the command “git add .” This command adds all the files to the staging area and all these files are now ready for the commit. And with the help of the command “git status” , you can check that all the files are inside the staging area. Also, you can see the file extension or the file name mentioned inside the “.gitignore”  are ignored by git. Step 5: Commit the files that are pre...

Lambda Expression

What is Lambda Expression? In java 8, a powerful concept is added named Lambda Expression.  Lambda expression is an anonymous function (a nameless function that does not have a modifier, return type, and even the type of its arguments).  Lambda expression is that you can pass to a method whose argument type is functional interface i.e. an interface that is either annotated by @FunctionalInterface  annotation e.g. interfaces from java.util.function package, or an interface with a single abstract method e.g. Comparable, Comparator, Runnable, Callable, ActionListener, etc.  Lambda expression allows passing customized code to the java method that was not possible before java 8. Although before Java 8 the only option was to wrap your code as an object and pass it using anonymous inner class to the method. Lambda expression defines parameters and code that executed using those parameters. Let's take the simplest example of the lambda expression (String input) -> ...

How to install IntelliJ IDEA on Windows?

System Requirements and steps to install IntelliJ IDEA on Windows System Requirements:  Step 1: Download IntelliJ IDEA. Click here. Step 2: Run the downloaded exe file and click on next. Step 3: Check the checkboxes mentioned in the below image and click on next and then hit the install button. Step 4: Final step is to reboot your system before start using IntelliJ IDEA. Thank you, guys. Please do comment below if there is any query or feedback.