File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "access specifiers" Watch "access specifiers" New topic

access specifiers

j srinivas

Joined: Apr 08, 2008
Posts: 16
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: 14074

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 7 API documentation
Scala Notes - My blog about Scala
j srinivas

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

Joined: Oct 27, 2005
Posts: 19655

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

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: access specifiers
Similar Threads
Doubt about diagram class (realization)
WA #1.....word association
Math class immutable
can non-static inner class access any member
andrew has wii