Skip to content

Instantly share code, notes, and snippets.

@jgwhite
Created February 18, 2011 11:11
Show Gist options
  • Save jgwhite/833547 to your computer and use it in GitHub Desktop.
Save jgwhite/833547 to your computer and use it in GitHub Desktop.
Java switch on String value
ValueEnum enumval = ValueEnum.fromString(myString);
switch (enumval) {
case MILK : lap(); break;
case WATER: sip(); break;
case BEER : quaff(); break;
default : dance(); break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment