Why would an Enum implement an Interface?

前端 未结 16 2743
长发绾君心
长发绾君心 2020-11-28 01:34

I just found out that Java allows enums to implement an interface. What would be a good use case for that?

16条回答
  •  清歌不尽
    2020-11-28 02:05

    Most common usage for this would be to merge the values of two enums into one group and treat them similarly. For example, see how to join Fruits and Vegatables.

提交回复
热议问题