Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use of Enums over Interface constants ?

 
Ramesh Kumar
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI
i need a clear idea about , why we go for Enum constants instead of interface constants .
what is the main difference ??
please post your comments on it .

Thank you
Rameshkumar
 
Harshit Rastogi
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Advantage of using enum:

1) can you in the switch case
2) can use the properties of an Enum class like using constructor etc
3) no need to implement the enum. can be used as an other class imported.

Prefer Enum only when all the constants belong to same category,. like No of days, Currencies etc.
 
Ramesh Kumar
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you .im clear now
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Constant Interface Anti-pattern
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic