File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 13868
    
  10

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
Difference between inner class and inner enum
Poker
declaring Enum variable as "final"
Java enums, space, and display values
Issues With Enum