Understanding Enums in Java

后端 未结 6 1892
Happy的楠姐
Happy的楠姐 2020-11-27 04:04

What are java enums? How do they work? Where could I used them and how?
Can I do without using enums in an app or are they so powerful that Its better to use them than i

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 05:00

    From my interpretation, enums are more for readability than anything else. They are basically used to replace values like 1-6 with more descriptive names, like [Happy, Sad, Angry, etc] You should use them whenever you need to use a small set of variables to describe the solution that you are expecting.

提交回复
热议问题