Java Enums can have behavior?

前端 未结 7 1398
清酒与你
清酒与你 2021-02-02 16:56

In Java, an Enum can do the great things that Enums do, but can also have methods (behavior and logic). What advantage does that have over using a class using an enum? Simple ex

7条回答
  •  迷失自我
    2021-02-02 17:23

    Because the enum instances are singletons, you can use them in switch statements or with == to check equality.

提交回复
热议问题