February 2014
Beginner
1248 pages
62h 25m
English
Figure 8.10 demonstrates instance variables, a constructor and methods in an enum type. The enum declaration (lines 5–37) contains two parts—the enum constants and the other members of the enum type. The first part (lines 8–13) declares six constants. Each is optionally followed by arguments that are passed to the enum constructor (lines 20–24). Like the constructors you’ve seen in classes, an enum constructor can specify any number of parameters and can be overloaded. In this example, the enum constructor requires two String parameters. To properly initialize each enum constant, we follow it with parentheses containing two String arguments. The second part (lines 16–36) ...
Read now
Unlock full access