File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

enum cannot be private or protected

 
Raja Narasimha
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Why enum cannot be private or protected ?
 
Henry Wong
author
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Actually, enums can be private or protect. It is just that top level enums that can't be private or protected.

Enums are very similar to Classes, and top level classes are not allowed to be private or protected. As for why top level classes can't be private or protected, please search the forums as this question comes up often.

As a quick summary though, it is less like it is not allowed, and more like there is no definition (what the compiler should do). The JLS doesn't define what is a top level private or protected class, and the definition for inner and nested classes doesn't apply. So, no definition mean you can't compile code which means that you can't allow it.

Henry
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic