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 private and protected enums 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 "private and protected enums" Watch "private and protected enums" New topic
Author

private and protected enums

Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
Hi,
I declared an instance enum with private/protected access modifier, The compiler did not flag any error. Whereas in the chapter one its mentioned that enums can only have public and default access. Can any one please clear my confusion?
Thanks
Deepak


SCJP, SCWCD, SCBCD
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Chapter one? Of what book? Possibly the book means that enums declared at top level can only be default or public?


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Ramamoorthy Periasamy
Ranch Hand

Joined: Feb 06, 2006
Posts: 30
I declared an instance enum with private/protected access modifier, The compiler did not flag any error. Whereas in the chapter one its mentioned that enums can only have public and default access. Can any one please clear my confusion?


If the enum declared out outside class then it should have only public or default access. Whereas, if the enum declared inside class then it may have private and protected too
 
 
subject: private and protected enums
 
Similar Threads
private class
enum cannot be private or protected
Private Class????
Enum member variable access
enums and protected modifier