O'Reilly logo

Java Quick Syntax Reference by Mikael Olsson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 19

image

Enum

An enumeration is a type that consists of a fixed list of named constants. To create one, the enum keyword is used followed by a name and a code block, containing a comma separated list of constant elements. The access level for an enumeration is the same as for a class. Package-private by default, but it can also be set to public if it is declared in a file of the same name. Just as with classes, an enumeration can be contained within a class, where it can then be set to any access level.

enum Speed{   STOP, SLOW, NORMAL, FAST}  

An object of the enum type above can hold any one of the four defined constants. The enum constants ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required