Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Protected Class?

 
Charlie Swanson
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In general, why can't we declare a protected class (that is not including inner classes)?
 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Charlie,
A 'protected' class can only be accessed by other classes within the same package or by any subclass. These conditions, for a top-level class, can all be met using the existing top-level class modifiers: 'abstract' and package (no modifier); which makes 'protected' redundant as a top-level modifier.

Hope that helps.

------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
 
Charlie Swanson
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jane,
Thank you for the answer. Could you give a short sample of how to declare it with abstract and package?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic