Guest User

Untitled

a guest
Jan 17th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. public enum introToEnum {
  2. //enum is converted to class internally.
  3. //all enums extend java.lang.Enum class. so it cannot extend anything else.
  4. ELSS("ELSS"),
  5. //this means ELSS is one of the enum.
  6. // this gets converted to --> public static final introToEnum ELSS = new introToEnum("ELSS");
  7. UNKNOWN("UNKNOWN");
  8.  
  9. private final String value;
  10. //we can have instance variables.
  11.  
  12. introToEnum(String value) {
  13. this.value = value;
  14. }
  15. //this is private constructor. so enum can't be instantiated.
  16. //this is invoked for each enum value.
  17.  
  18.  
  19. public String getValue() {
  20. return value;
  21. }
  22. //we can only have concrete methods inside enum.
  23. }
Add Comment
Please, Sign In to add comment