I have an Enum class below
public class PTalkCommand { public enum Code { CLR((byte) 0), ACK((byte) 170), SER((byte) 0), NAK
There's a built-in .values() method that returns an array of all the enum constants. You can iterate it backwards.
.values()
Code[] values = Code.values(); for (int i = values.length - 1; i >= 0; i--) { Code next = values[i]; //do your thing }