Language Updates

Learn about language updates made in Java 7.

The following features have been added to the Java language:

  • Diamond operator
  • Strings in switch
  • Automatic resource management
  • Improved exception handling
  • Numbers with underscores

Diamond operator

The Diamond operator simplifies the declaration of generic classes. The generic types are inferred from the definition of the field or variable.

Map<String, List<Double>> nums = new HashMap<String, List<Double>> ();

For example, the above code can also be written in Java 7 as:

Map<String, List<Double>> nums = new HashMap
...