Compare hotel prices and find the best deal - HotelsCombined.com

Sunday, July 27, 2014

Java 5 (J2SE 5.0/JDK 1.5) New Features

Java 2 Platform Standard Edition 5.0 (J2SE 5.0 or Java 5 or JDK 1.5) came up with a full bunch of significant new features which are very useful for java developers as well as for JVM in order to improve performance. In this tutorial, you can find some important J2SE 5.0 new features added in JDK 1.5 which are part of day-to-day java coding.
List of most commonly used Java 5 new features:
  1. Generics for Collections
  2. Enhanced for Loop (for-each loop)
  3. Autoboxing/Unboxing
  4. Typesafe Enums
  5. Varargs/Vargs (Variable-length Argument Lists)
  6. Static Import
  7. Metadata (Annotations)
  8. Formatting
  9. Scanner

What is new in Java 7 - Top 5 JDK 7 feature

Top 5 new features in Java 7

What is new in Java 7 - new JDK 7 featureHere is my favorite Top 5 new Java 7 features introduce in Java programming language on release 7. There are many more features in Java 7 which is introduced along with these front-line feature like File API changes which is also worth exploring.

Allow using String in Switch case
You can not use String in Switch or case statement prior to Java 7. Talk of allowing String in Switch case was growing ever since Enum was introduced in Java 5, though you can use Enum in Switch case, you can not do the same with String which is more common than Enum in Java programming language. from JDK 7 you can use String in Switch case, see How to use String in Switch case in Java7 .


Multiple Exception in one catch block
This is the first feature which comes in my mind when people ask What is new in Java 7 feature ? can you name few new feature introduced in JDK 7 release? From JDK 7 you can catch multiple Exception in one catch block. This is calledmulti-catch block feature of Java 7. This is a significanimprovement Java 7 made in Exception handling because it will reduce clutter in Exception handling code in Java.


Automatic resource management or ARM blocks
Similar to previous Java 7 feature, Automatic resource management (ARM blocks) also known as try with resource block is another significant improvement in area of Exception handling in Java. ARM blocks allows automatic closing of resource e.g. Files, Streams etc, opened inside try block. Resource needs to implement Closeable interface in Java. 


Fork Join framework in Java 7
What is new in Java 7 ?  Fork join framework exists even before Java 7 but as a separate JSR. It has been added as new feature in Java 7 to make it part of standard Java 7 core library. Fork join framework allows you to write code which can take advantage of multiple cores present in modern servers. See How to use fork join framework in Java 7 for code example and guide on using fork join framework.


Diamond operator <> for type inference
Every since Java 5 introduced Generics in Java, programmers are complaining that its very verbose and generate duplicate code, which is true because while creating object of parameterized class in java you need to provide type parameters in both left and right hand side. Diamond operator <> is a new Java 7 feature which provides type inference while creating object of Generic classes. Though you can achieve type inference without using Java 7 as well by creating Factory method in Java, Diamond operator is easy way to achieve type inference in Java 7.

These were my list of Top 5 new features introduced in Java 7 release and now you can answer What is new in Java 7. These were some of the most popular new features of JDK 7. Many production system is still running on various JDK 6 update but I assume they will also slowly upgrade to Java 7. Now days even talk of Java 8 is growing as it may introduced closures in Java, which was earlier planned to be release in Java 7 release along with these new features.