• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

access specifiers

 
j srinivas
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15448
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
j srinivas
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply.
 
Rob Spoor
Sheriff
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And the alternative, default access, gives non-derived classes in the same package access as well.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic