Why Java 8 ?

With this new release, Java 8 is introducing a completely new JVM with full packed of some really exciting features at both the JVM and programming language level.

There are literally dozens of new features that make java even better than previous versions and improvement about performance and optimized coding level with some functional programming features. These additions are under-the-hood improvements either at the compiler, JVM or help-system level.

  • Lambda Expression and Virtual Extension Methods are the highlighting feature of Java 8 which is the implementation of Lambda expressions and supporting features to the Java programming language and platform.
  • To overcome external iteration, Java 8 Stream API was introduced. We can use Java Stream API to implement internal iteration.
  • To use lambda expression, we need to create either our own functional interface or we can use pre-defined functional interface provided by Java-8 with @FunctionalInterface.

 

  • Java 8 introduced forEach() and forEachOrdered() method to iterate over Collection and streams.
  • Internal iterationprovides several features such as sequential and parallel execution with multithreaded environment.
  • Stream operations have two functional characteristics: 

                                           i) Pipelining and ii) Internal Iteration

  • Java 8 added new Optional type gives developers most significant flexibility when dealing with null values, which reduces the likelihood of NullPointerExceptions.
  • In many cases, Java 8 will improve application performance without any specific work or tuning by using multithreaded environment.
  • Java 8 new Date and Time API will allow developers to handle date and time in a more efficient and natural way.
  • A new JavaScript engine “Nashhorn” is integrated with Java 8. When we integrate JS into backend that we don’t worthier about setting up node.js instance, we can simply use JVM to execute the code.
  • Concurrent Accumulators enable you to very efficiently increase / decrease the value of a counter in a thread safe manner. This is really a case where it’s not a question of taste, or preference – using these new classes in your code is really a no-brainer.
  • Java 8 provides Improved Security which replaces the existing hand-maintained list of caller sensitive methods with a mechanism that accurately identifies those methods and it allows its callers to be discovered reliably.
  • Aggregate operations:Streams support SQL-like operations and common operations from functional programing languages, such as filter, map, reduce, find, match, sorted, and so on.
  • In Java 8 , staticand default keyword to create interfaces with method implementation. forEach method implementation in Iterable interface is:
default void forEach(Consumer<? super T> action) {
Objects.requireNonNull(action);

for (T t : this) {
action.accept(t);
}

}

Since, Java doesn’t provide multiple inheritance in class level because it leads  to Diamond Problem. So how it will be handled with interfaces now, since interfaces are now similar to abstract classes.

  • parallelSort() method introduces with the multi threaded concept which makes it much faster than previous sorting methods. The parallel sort uses Fork/Join framework.
  • Java 8 has introduced  forEach method in lang.Iterable interface so that while writing code developers only focus on business logic only.
  • The :: operator is used to make method reference to separate the Class and Object from the method name.
Eg: str -> System.out.println(str)
System.out::println
  • A Part of these improvements java 8 improves some miscellaneous core API improvements Like:
    • ThreadLocal static method withInitial(Supplier supplier) to create instance easily.
    • min(), max() and sum() added in Integer, Long and double wrapper classes.
    • logicalAnd(), logicalOr() and logicalXor() methods in Boolean classes.
    • To invoke javascript “Nashrom” engine jjs command is added.
    • For Zip file entries, ZipFile.stream() method to get an ordered stream over zip file entries
    • Various utility methods added in Math class.
    • Comparator interface extended with a lot of default and static methods for natural ordering or reverse order etc.
    • To analyze class files a new command “jdeps” has been added.
    • JDBC-ODBC bridge and PermGen (Permanent Generation) memory space has been removed.
    • jis command is added to invoke Nashorn Engine.

Share Knowledge
This entry was posted in Java, Java 8 and tagged , , . Bookmark the permalink.

12 Responses to Why Java 8 ?

  1. upendra yadav says:

    Nice information, In some mins get to know new concepts of java8 has introduced.

  2. PRAVEEN YADAV says:

    I am a computer science student so its very important to have good command on Java. I once opened this code-adda.com during my exams and it was really helpful. This site is so such informative that one does not need to open books for looking up for the core concepts. It covers everything from basic to advance java.The quality of examples given are aplaudable. MCQs are also given related to every concept that too not the basic questions but some high level ones where you need to use your brain. The site layout is also good and according to me layout doesnt matter if the content provided is too awsome. Moreover learning here is completely free , so no need to take up any extra couse for JAVA , it has vey useful content. Not even Java but it provides courses on other languages also which I didnt study but what study was remarkable and that is JAVA. The laguauge used is also easy to understand and every point is made clear by giving proper example.

    *****

  3. Kumar Anand says:

    Its very usefull for lerner great tutoril thanks vikas bro…
    Waiting for next….

  4. Raushan Gupta says:

    Information about Java 8 😇
    Thanks vikash sir

  5. Lajul soni says:

    Great …. it’s very helpful😊.

  6. Pankaj Kumar says:

    Nice article on Java 8.
    Waiting for your upcoming book Sir.

  7. Suraj Kumar Gupta says:

    Wow Grt…

    Keep it up bro 😋

  8. DEEPAK AGRAWAL says:

    Good article.. Got to know about java 8 ..thanks

  9. Dipanshu Kumar says:

    Valuable information abt Java 8 thanks.

Leave a Reply

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