Getting error "Cannot find symbol" in line a=Monday and can't understand why.
Have tried moving the declaration of enum WEEKDAYS into every possible scope but still doesn't work. Even tried putting the enum declaration in a separate file as a public enum. Please can anyone tell me where this is wrong.
I'm going to say my worthless opinion here, but before I post something on the forums, I usually do my homework just within a few clicks you would have all the info you need. But anyway, here's what I have learned about enumerations: All enumeration constants are actually objects of it's enumeration type. All enums automatically inherit java.lang.Enum class, which has predefined methods like Ordinal() & compareTo(), so all of your constants will have access to those methods. Enumerations act like classes, although you don't initiate enums with new , you simply create referance variable of the enum type: SomeEnum a; . As you might guess, each object in enum is implicitly final. , so you usually assign value using constructor lie this:
then when you create variable of enum type, constructor will be called for each constant in enum. You can print value of each constant, just like you do with static members EnumName.Member . Also, you can use enum constants to control switch statement.
Bear Bibeault wrote:You have been given ample clues. Think!
I was looking for an answer, not clues.
If you haven't got anything useful to add then please don't bother posting on my threads, thanks.
That's not how things work around here, I'm afraid. There are certain things you should know about this community to understand why you're getting the kind of replies you're getting. Start with these pages: NotACodeMill (<--click) and ShowSomeEffort (<--click).