Monday, December 07, 2009

New features in Java 7: Switch on Strings

At last there is this feature is in Java 7

String s = "something something something"
switch(s) {
case "Jayanagar":
goToOxford(s);
break;

case "Rajajinagar":
case "Navrang":
haveDosainAjanta(s);
break;

default:
goToBrahminsCoffeebar(s);
break;
}
More on ... http://java.sun.com/features/jdk/7/

No comments: