This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

call constructor from super-enum

 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
call super()-Konstruktor from enum?

I have this:

 
Campbell Ritchie
Sheriff
Pie
Posts: 50240
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't have any constructors there; you have methods called Construct. The name of the constructor has to be exactly the same as the name of the class (or the enum).
You can't call a superclass constructor because you don't have an "extends" declaration. I don't know whether an enum can have an "extends" declaration or not, however. There is something about enums in the Java Tutorials.
 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

thanks.

by the way, enum can not have (more than one) "extends"..
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:I don't know whether an enum can have an "extends" declaration or not, however. There is something about enums in the Java Tutorials.

It can't - the extend clause (extends Enum<X> where X is your enum name) is implicit.

As for the sole constructor in class Enum, that is also implicitly called already, so calling super(name, ordinal) is not allowed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic