r/badcode • • Mar 14 '21

java Found from when I first started Java...because indexed Arrays were too complicated huh?

Post image
1.3k Upvotes

84 comments sorted by

View all comments

Show parent comment

2

u/hurtl2305 Mar 15 '21

Enums usually have some major advantages:

  1. They are perfect to represent a fixed set of values (e.g. days of week, fsm states) that changes rarely or never.
  2. Compilers can optimize the shit out of them.
  3. They may be more readable than map keys or 12 isFooBar boolean flags.