Nesting enums in Java

前端 未结 3 1703
一个人的身影
一个人的身影 2021-02-14 06:33

I want to nest some enums. The object i\'m representing are Flags, with a type, and a value. There are a discrete number of types, and each type has a distinct set of possible v

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-14 07:24

    Nesting enums is not possible. But enums can implement interfaces. Why not have A and B as two different enums that both implement a TypedEnum interface with getType() and getValue() methods?

提交回复
热议问题