Power of Enums in Java

It comes sporadically that one has to implement a state machine for a project. Be it a benchmarking tool, or an authentication backend, or a Markov chain generator, it boils down to having a variable in one state, moving to another on certain action. In some of the cases, it might be quite useful to probabilisticaly move among states. There are many ways to implement such behaviour, but I found one really elegant, using Enum in Java.