GeeCON Prague 2014*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Why Enum type are not  extended futher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Why Enum type are not  extended futher" Watch "Why Enum type are not  extended futher" New topic
Author

Why Enum type are not extended futher

kaushik vira
Ranch Hand

Joined: Feb 01, 2007
Posts: 102
By default enum type is consider as final we can`t further extend it. can any one give me good like to refer all the rule of enum.

enum Day{Monday, Sunday}

public class Test extends Day{

public static void main(String[] args){
Day d = null;
System.out.println(d.Monday);
}
}

After all Day will become a normal class, is there any specification that it`s internally marked as final.


kaushik Vira
-------------------------------------
SCJP, Preparing SCWCD..
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14193
    
  20

You could regard an enum as a special kind of class.

You can't extend an enum with another normal class - that would be very strange. What would a class that extends an enum be - some strange kind of enum with extra stuff added?

You also can't extend an enum with another enum. This page from Sun's tutorials explains why:
Note: All enums implicitly extend java.lang.Enum. Since Java does not support multiple inheritance, an enum cannot extend anything else.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
 
subject: Why Enum type are not extended futher