What’s new in Java 7- Features as part of Project Coin

As part of the Project Coin, there were quite a few language enhancements were added to the Language. The last time Java language changed was in the Java 5 release when Generics were added. The changes in introduced in the Java 7 were welcomed by java community around the world. This was seen as a stepping stone to the plethora of changes to be introduced with Java 8 and above. Nonetheless Java 7 has its own set of issues, but this shouldn’t be a concern for someone to download the latest build and give it a shot.

Look at the redundancy of code in both the catch blocks. With the introduction of Mutli catch blocks, the same catch block can be used to capture multiple exceptions thereby leading to code reuse. So the modified code would be:

Now coming to the underscores in numeric literals: Pre Java 7, we would write something like:

int hugeNumber = 1000000000;

A trivia now: How fast can you count the number of zeros in hugeNumber? The time taken to count the number increases with the age of a person. Jokes apart, lets see how this is can be changed with Java 7 enhancement:

These were some of the few enhancements added as part of Project Coin in Java 7 release. There are few more features which were pushed to Java 8 and another feature try-with-resources ( Automatic Resource Management) which is part of Java 7 and I would write about it in my upcoming posts.

If you are interested in obtaining a fully functional code, please do it from here. Note: In order to run the examples given above you need to download the JDK 7 from here.

[…] happening in the Java community. You must have seen plethora of articles on try-with-resources, strings in switch statements and other minor language enhancements as part of Project Coin. These are just few of the […]