Posts

Showing posts from August, 2011

New in Dolphin - Java 7

With Dolphin java introduced cool new features like:

1. Strings in “switch” block

     switch(s) {
          case “Apple”:
          // do something;

          case “Orange”:
          // do something;


          default :
     }



     2. <> (Diamond) operator – Type inference for generic instance creation
E.g List > list = new ArrayList>();
vis-à-vis
List > list = new ArrayList <> ();
Empty diamond braces is required and it's not a typo :).



     3. Single Catch for multiple Exceptions with "|" operator
          try {
          // Reflective operations calling Class.forName,
          // Class.newInstance, Class.getMethod, Method.invoke, etc.
     } catch (final ClassNotFoundException |      InstantiationException | NoSuchMethodException |      InvocationTargetException e) {
          log(e)
          throw e;
     }


     4. Also in Java 7, this will work
     public void rethrowException(String exceptionName) throws FirstException, SecondException {