enum.values() - is an order of returned enums deterministic
Yes, it is a guaranteed to return them in that order.
However you should avoid relying on that, and on the ordinal()
value, since it can change after inserting new items, for example.
It is determined by the order your values are declared in. However, there is no guarantee that you (or someone else) won't reorder / insert / remove values in the future. So you shouldn't rely on the order.
Effective Java 2nd. Edition dedicates its Item 31 to a closely related topic: Use instance fields instead of ordinals:
Never derive a value associated with an enum from its ordinal; store it in an instance field instead.
The Java language specification uses this explicit language:
@return an array containing the constants of this enum type, in the order they're declared [Source]
So, yes, they will be returned in declaration order. It's worth noting that the order might change over time if someone changes the class so be very careful about how you use this.