Hi Schnoof,
ich weiß zwar immer noch nicht was du eigentlich erreichen willst, aber seis drum.
Ich hab dein Code Schnippsel in Eclipse geworfen
Compiler Compliance level: 6.0
JRE: jdk1.6.0_02
Funktioniert problemlos.
wenn ich in ++ABC.lettersCounter das ABC weglasse funktioniert es interessanter weise nicht mehr.
in jdk1.6.0_02 funktioniert es gar nicht.
Letzteres entspricht auch der aktuellen Spezifikation:
It is a compile-time error to reference a static field of an enum type that is not a compile-time constant (§15.28) from constructors, instance initializer blocks, or instance variable initializer expressions of that type. It is a compile-time error for the constructors, instance initializer blocks, or instance variable initializer expressions of an enum constant e to refer to itself or to an enum constant of the same type that is declared to the right of e.
aus: http://java.sun.com/docs/books/jls/third_edition/htm…
Dies ist notwendig, da für die Enumkonstanten ja static fields erzeugt werden. Und nicht klar ist, wer da wann in welcher Reihenfolge Instanziert werden soll.
Daher würde ich das bis auf weiteres als Fehler vom Eclipse Compiler und vom JDK1.5 einstufen
Eine korrekte Lösung (bis auf den konstanten Summanden 1) des Problems wurde ja schon geliefert.
Jens