Java 7, also known as Project Coin also improved Java's exception handling with the introduction of Muti-Catch Exception and Final Rethrow supports. With Multi-catch you will now be able to catch multiple exceptions in single block contrary to Java 6 or earlier where this isn't possible.
In the previous posts, I used a multicatch feature in the Cryptography examples.
Despite the fact that in the previous code, the method encrypt_data() throws an exception.
Nov 8, 2012
Nov 6, 2012
Java 7 Overview: Automatic Resource Management
Java 7 support Automatic Resources Management through the try-with-resources statement. A resource is an object that must be closed after the program is finished with it. The try statement could declare one or more resources, where it ensures that each resource is closed at the end of the statement. Any object that implements java.lang.AutoCloseable, which includes all objects which implement java.io.Closeable, can be used as a resource in this regard.
Nov 2, 2012
Java 7 Overview: String in Switch Support
Prior to Java 7, Switch statements work either with primitive types or enumerated data types.
Java 7 introduced ability to Switch on String type.
The issue worth mentioning about switch statement when used with a String type is, it uses equals() method to compare the expression pass to it, with each value in the case statement, which made it case-sensitive and will throw a NullPointerException if the expression is null.
As a result, checking for null parameter and converting the string to lower
The issue worth mentioning about switch statement when used with a String type is, it uses equals() method to compare the expression pass to it, with each value in the case statement, which made it case-sensitive and will throw a NullPointerException if the expression is null.
As a result, checking for null parameter and converting the string to lower
Subscribe to:
Posts (Atom)