-1

It is known that Interface doesn't need constructor because all the data members of interface are public,static and final. Similarly enum also has all its constants as public static and final then how come it needs/had a constructor?

Ramya
  • 7
  • 2
    The members of an enum can have arbitrary data members that need arbitrary initialization. – user13784117 Aug 12 '20 at 12:07
  • 8
    There are no direct instances of an `interface` (only instances of classes implementing that interface). But there *are* instances of `enum` (all enum values are instances of their respective enum type). – Joachim Sauer Aug 12 '20 at 12:07
  • Related: [interface vs abstract class](https://stackoverflow.com/questions/1913098/what-is-the-difference-between-an-interface-and-abstract-class) and [interfaces vs enums](https://stackoverflow.com/questions/2528561/interfaces-vs-enums) – Lino Aug 12 '20 at 12:09
  • Checkout this link for clarification: http://web.mit.edu/6.031/www/sp17/classes/14-interfaces/ – Mojtaba Aug 12 '20 at 12:32

1 Answers1

5

An interface cannot be instantiated, an enum can (and in fact will be, as each of its members is an instance of the enum itself).

jwenting
  • 5,505
  • 2
  • 25
  • 30