admin管理员组

文章数量:1642440

List of points:

  1. The enum in JAVA is in fact a special class
    1. Each constant in the enum is an instance. The instance is implictly the 'static' and 'public'
    2. The (implicit) constructor of the enum is private and so user can never construct a new enum constant after it's defined.
  2. You can add more methods to the enum but the constants shall always be defined at the beginning.
  3. Every enum implicitly contains below two methods
    1. valueOf(String) return the enum instance by its name string.
    2. values() returns the array of enum instances
  4. The enum can be sophiscated coded and designed but usually it's simple enough. If you design a sophiscated enum, it may mean 'enum' is not suitable to your needs.
  5. Even though it's the class/instance, it can be directly used in the switch case context.

本文标签: Javaenum