Skip to content
- “cannot be subclassed” isn’t a restriction. It’s one of the big advantages: It ensures there there is always only ever exactly the set of values defined in the
enum
and no more!
enum
correctly handles serialization. You can do that with type-safe enums as well, but it’s often forgotten (or simply not known). This ensures that e1.equals(e2)
always implies e1 == e2
for any two enum
values e1
and e2
(and vice versa, which is probably more important).
- There are specific lightweight data structures that handle enums:
EnumSet
and EnumMap
(stolen from this answer)
Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)