Java 8: What’s new?

Java 8

Heard about Java 8? Excited about Java 8? Wanna know about Java 8? If so, then you can continue to read this article.

If you have heard about Java 8 then you might noticed people saying that it is going to change the world of Java community and it is going to have many new revolutionary features that Java was lacking in its previous releases and will features a new performance optimized platform.

Here we will provide list of changes and new features added to Java 8. In case you are more concerned about Java 8, here is the official link.

Let’s talk about new changes and features in Java 8:

Here is the details and examples:

Lambda expressions

Lack of this feature bothered Java community a lot and Anonymous classes used till now are not up to the mark as still we needed that same boilerplate code but now with Java SE 8 it‘s going to feature Lambda Expressions that brings mush ease in development. Lambda expressions can be thought as a shortcut of anonymous classes so there is nothing we can do with regular expressions that we can’t do without regular expressions.

So let’s know what’s so exciting about Lambda expressions and how it works. Suppose you want to pass an object to a function for some purpose, as of Java 7 you need to create a new class or Anonymous class for that purpose.

#1 – Lets say, in first example below we want to compare the use of Runnable class with and without Lambda, check this out.

Output #1:

#2 – Second example below will use Lambda expression to show the items in List:

Output #2:

From PermGen to MetaSpace

In Hotspot JVM (1.8) the infamous Permanent Generation space is removed just like in JRockit JVM and IBM JVMs. Let’s know more about this change.

Before:
There was a particular space in Permanent Generation space in Java memory model that stored class metadata and every information about a normal class as a Klass.

Now:
PermGen space is removed and information will now be stored in native memory. Although MetaSpace too can be configured as PermGen.

New Date/Time API

Java 8 features a new Date/Time API. If you have used old Date/Time API if must have tired of frustrating things like 0-based month index, 1-based day index and many other pains. Although there is a nice JodaTime 3rd-party API that is much easier but now a whole new very efficient API will be housed by default in Java 8 as java.time package.

New Collection features

Collection API was already very powerful and was able to fulfill most data structure needs but with Java 8 there is much more that old collection API, it now features many handy methods that we used to implement by ourselves till Java 7.

New JavaScript engine

Nashorn is the new, lightweight, high-performance implementation of JavaScript integrated into the JDK. Nashorn is the successor to Rhino, with improved performance and memory usage. It will support the javax.script API, but will not include support for DOM/CSS nor include a browser plugin API.

Core feature improvements
  • Functions can now have defined static methods
  • Generic type inference improvement
  • Functional interfaces
  • Method references (compact Lambda expressions)

Let’s grab it and learn more and more about Java 8 while it is still hot, you can download Java 8 in this link.

You also can find some articles about Core Java here.

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*