Sunday, December 4, 2011

jdk7 new features

switch on String
Before JDK 7, only integral types can be used as selector for switch-case statement. In JDK 7, you can use a String object as the selector. For example,

http://www3.ntu.edu.sg/home/ehchua/programming/java/JDK7_NewFeatures.html
http://www.eweek.com/c/a/Application-Development/Oracle-and-Java-7-The-Top-10-Developer-Features-626145/

Java Generics

Generics also provide compile-time type safety that allows programmers to catch invalid types at compile time.

It would be nice if we could write a single sort method that could sort the elements in an Integer array, a String array or an array of any type that supports ordering.

we can print array of different type using a single Generic method

http://tutorials.jenkov.com/java-generics/implementing-iterable.html
http://www.oracle.com/technetwork/articles/javase/generics-136597.html
http://www.tutorialspoint.com/java/java_generics.htm