• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why Enum type are not extended futher

 
kaushik vira
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15441
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic