We would like to know how to get next in static enum.
enum Planet {/*from w ww .j a v a2 s . co m*/ EARTH, MARS; Planet() { } public Planet getNext() { return values()[(ordinal() + 1) % values().length]; } } public class Main { static Planet current = Planet.EARTH; public static void main(String[] args) { setNext(); } public static void setNext() { current = current.getNext(); } public static Planet getCurrent() { return current; } }