Community
Participate
Working Groups
I have constructed the following class the demonstrate the problem: import java.util.*; public class Card { public enum Rank { DEUCE, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE } public enum Suit { CLUBS, DIAMONDS, HEARTS, SPADES } private Card(int rank, int suit) { } private static final List<Card> protoDeck = new ArrayList<Card>(); public static ArrayList<Card> newDeck() { return new ArrayList<Card>(protoDeck); // Return copy of prototype deck } } When I create the file by copying the text into the Java editor everything compiles. Then I comment out the line 'public enum Suit ..' etc; I enter exactly the same line again by typing it; the result is that my class now has 2 compile errors. The first one is in the declaration of 'Suit': it says 'Syntax error, insert 'Enumbody' to complete EnumDeclaration. The second one is in the constructor of Card: it says 'Illegal modifier for the enum constant Card: no modifier is allowed. When I close the Java editor and open the Card class again, it contains no compile errors anymore. I'm using the final version of JDK 1.5 and Eclipse 3.1 M3.
Verified (in I20041214-2000) that you get no error after manully typing the enum declaration.