Sunday, October 07, 2012

What are some new features in the latest version of Java

Believe me, this is got to be one of the most common questions across various interviews. Being honest as always pays the dividends here. No fun in saying that you have worked in Java 7, when you haven't.

For the purpose of this post listing below some of the key features (amongst the hundreds released along with )introduced with Java 7


  1. Diamond Operator <> - Gives you the ability to use Generics without declaring the data types both sides of the = operator. E.g. Map> trades = new TreeMap <> ();  instead of Map> trades = new TreeMap> ();
  2. Ability to use String statements with SWITCH - Restricted to just being used with enums and primitives, Java 7 gives us an ability to use switch statements with Strings which is a life saver and helps us to get rid of those long if then else statements.
  3. Numerals with underscore - Again more from a readability perspective you now have an option of declaring 1 million as int temp = 1_000_000 for better readability perspective
  4. Support for extensions in JVM to support dynamic languages

References

No comments: