Enum.values() vs EnumSet.allOf( ). Which one is more preferable?

后端 未结 6 1245
滥情空心
滥情空心 2020-12-23 09:05

I looked under the hood for EnumSet.allOf and it looks very efficient, especially for enums with less than 64 values.

Basically all sets share the singl

6条回答
  •  离开以前
    2020-12-23 10:02

    There is also Class.getEnumConstants()

    under the hood they all call values() methods of enum types anyway, through reflection.

提交回复
热议问题