Switching Java

by bitznbitez

Finally at long last with Java 1.7 the switch statement will support strings.  This allows such wonderful code blocks as :

switch(myDatabaseTypeString.toUpperCase()){
  case "DB2": 
     myDatabaseType=Database.DatabaseType.DB2;
     break;
   case "POSTGRES":
     myDatabaseType=Database.DatabaseType.POSTGRES;
     break;
   default :
     myDatabaseType=Database.DatabaseType.UNSUPPORTED;
     break;
}

Which to me is a truly wonderful thing.

Happy Coding !

Advertisements