Java 8 – New features and Advantages

Spread the love

Java 8 has brought about many new advancements and kind of convenience for Java developers. Let us go through the new features which were added in Java 8. We will go into detail into each of those in the subsequent tutorials.

New features:

  1. Lambda Expression – A method definition without any method name. 🙂 Magic right? It is a statement or a sequence of statements which you can say as logic or method definition. It takes arguments and returns an output.
  2. Steam API – Converting a collection of data to a sequence of stream so that it is iterated as when required. It is lazy operation.
  3. Functional Interfaces – An interface having a single abstract method.
  4. Optional Class – It is a class which is used to avoid null pointer exception.
  5. Method Reference – Calling methods of a class using a simple way.
  6. Nashorn Javascript engine – Much improved Javascript engine with much better performance than it’s previous version Rhino.

There was also a default method feature added in which interfaces can now have default method implementations in them.

Advantages:

-> More Compact code and less boiler plate code.

-> More readable code

-> More testable code.

In the next tutorials we will go through each of the above new features to know more about it.