Enum in Java

Chapter 15 - Enum

    Enum in Java

  • Enum

              Enum is type like class and interface and can be used to define a set of Enum constants. Enum constants are implicitly static and final and cannot change there value once created.

              Enum in Java provides type-safety and can be used inside switch statment like int variables. Since enum is a keyword you can not use as variable name.

              Java Enum as type is more suitable to represent well known fixed set of things and state, for example representing state of Order as NEW, PARTIAL FILL, FILL or CLOSED.

              Enumeration(Enum) was not originally available in Java though it was available in other language like C and C++ but eventually Java realized and introduced Enum on JDK 5 (Tiger) by keyword Enum.

© 2015 by Learncertification All Rights Reserved. The certification names are the trademarks of their respective owners. Terms & Privacy Policy