Enumeration

Enumeration is just like a class but it is used for defining constants.
It Behaves just like a class only we can declare constant objects in it

  1. enum EventType{
  2. Arrive (1),
  3. SERVE(2),
  4. Wait(3), //this is calling the constuctor
  5. Leave(4),
  6. DONE(5)
  7. private int type;
  8. EventType(int type){
  9. this.type = type;
  10. }
  11. }
Each constant of an enum type is an instance of enum class and is a field declared with public static final
<Prev Streams and Function Interfaces

No comments:

Post a Comment