Jesse Silverman wrote:Your first priority is to figure out which things you can do with enums is on the exam.
Then how to do those things correctly, and spot incorrect usage attempts.
The lowest priority is how you want to describe this behavior in brief.
The full description is way beyond the scope of the exam, and can be seen in the JLS.
Yes, but more so.
Antonio Moretti wrote:. . . the enum Book in my example is like a class, and the fields it contains are like instances of that class. . . .
Look in the Java™ Tutorials and the Java® Language Specification which have all sorts of examples about enums. An enum constant with its own methods is (I think) regarded as an instance of a subclass of the enclosing class.
Jesse Silverman wrote:. . . instances of a class (in Java) do not get the option of implementing their own versions of class methods. . . . enum's do have precisely this ability . . .
Jesse Silverman wrote:You don't need to provide methods in your enum, and I had never done this before in my life before learning this relatively recently in Java and C# about the same time.
Effective Java by Joshua Bloch, 1st edition (2001) page 80.
Jesse Silverman wrote:. . . how we used to do such things in those days . . .