public class EnumTest9 { private enum State { START { public State nextState() { return State.RUNNING; } }, RUNNING { public State nextState() { return State.STOP; } }, STOP { public State nextState() { return State.STOP; } }; public abstract State nextState(); } public static void main(String[] args) { State state = State.START; System.out.println("Present State is " + state); state = state.nextState(); System.out.println("Next State is " + state); state = state.nextState(); System.out.println("Last State is " + state); } }