Imagine the following made up example:
public enum Hand {
ROCK(SCISSORS),
PAPER(ROCK),
SCISSORS(PAPER);
private final Hand beats;
Hand(Hand beats) {
this.beats = beats;
}
}
I will get an error Illegal forward reference
for forward referencing SCISSORS
.
Is there a way to handle such forward references in Java?
Or how would you model such a situation, where you have a logical circular reference between several enums values?
Illegal forward reference
error information. – Extantswitch
inside a method. – Ulla