wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes call constructor from super-enum Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "call constructor from super-enum" Watch "call constructor from super-enum" New topic
Author

call constructor from super-enum

nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
call super()-Konstruktor from enum?

I have this:

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38487
    
  23
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

Joined: Jun 28, 2008
Posts: 580
hello,

thanks.

by the way, enum can not have (more than one) "extends"..
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19682
    
  19

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
jQuery in Action, 2nd edition
 
subject: call constructor from super-enum