This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes access specifiers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "access specifiers" Watch "access specifiers" New topic
Author

access specifiers

j srinivas
Greenhorn

Joined: Apr 08, 2008
Posts: 16
hi,
i want to know whether we can make a class visible to all the derived classes in same package.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14952
    
  26

There is no way to make a class visible only to derived classes in the same package.

'protected' makes a class visible to derived classes, but also derived classes in other packages, and it also makes the class visible to other classes (that are not derived from the class) in the same package.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
j srinivas
Greenhorn

Joined: Apr 08, 2008
Posts: 16
thanks for the reply.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20078
    
  30

And the alternative, default access, gives non-derived classes in the same package access as well.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
 
Have you checked out Aspose?
 
subject: access specifiers
 
It's not a secret anymore!