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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.