Chapter 6. Static, Final, and Enumerated Types

  • What Field Modifier static Means

  • What Field Modifier final Means

  • Why Enumerate a Type?

  • Statements Updated for Enumerations

  • More Complicated Enumerated Types

  • Some Light Relief—The Haunted Zen Garden of Apple

image

Enumerated types were brought into Java with the JDK 1.5 release. They are not a new idea in programming, and lots of other languages already have them. The word “enumerate” means “to specify individually”. An enumerated type is one where we specify individually (as words) all the legal values for that type.

For a type that represents t-shirt sizes, the values might be small, medium, ...

Get Just Java™ 2 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.