> For the complete documentation index, see [llms.txt](https://hanfak.gitbook.io/workspace/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hanfak.gitbook.io/workspace/languages/java/effective-java/enums-annotations.md).

# Enums and Annotations

* [Enums and Annotations](#enums-and-annotations)
  * [Use enums instead of int constants](#use-enums-instead-of-int-constants)
  * [Use instance fields instead of ordinals](#use-instance-fields-instead-of-ordinals)
  * [Use EnumSet instead of bit fields](#use-enumset-instead-of-bit-fields)
  * [Use EnumMap instead of ordinal indexing](#use-enummap-instead-of-ordinal-indexing)
  * [Emulate extensible enums with interfaces](#emulate-extensible-enums-with-interfaces)
  * [Prefer annotations to naming patterns](#prefer-annotations-to-naming-patterns)
  * [Consistently use the Override annotation](#consistently-use-the-override-annotation)
  * [Use marker interfaces to define types](#use-marker-interfaces-to-define-types)

## Use enums instead of int constants

## Use instance fields instead of ordinals

## Use EnumSet instead of bit fields

## Use EnumMap instead of ordinal indexing

## Emulate extensible enums with interfaces

## Prefer annotations to naming patterns

## Consistently use the Override annotation

## Use marker interfaces to define types
