This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 14074
    
  16

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 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why Enum type are not extended futher
 
Similar Threads
Java enums, space, and display values
Difference between inner class and inner enum
declaring Enum variable as "final"
Poker
Issues With Enum