Skip to content

Instantly share code, notes, and snippets.

@wytten
Created March 28, 2013 18:20
Show Gist options
  • Save wytten/5265580 to your computer and use it in GitHub Desktop.
Save wytten/5265580 to your computer and use it in GitHub Desktop.
Getting the "next" value of a Java enumeration
public enum Player {
SOUTH, WEST, NORTH, EAST;
public Player next() {
int index = (this.ordinal() + 1) % values().length;
return values()[index];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment