Why can't sub-packages see package private classes?

Posted by Polaris878 on Stack Overflow See other posts from Stack Overflow or by Polaris878
Published on 2010-03-21T22:54:53Z Indexed on 2010/03/21 23:01 UTC
Read the original article Hit count: 380

Okay so, I have this project structure:

package A.B

  • class SuperClass (this class is marked package private)

package A.B.C

  • class SubClass (inherits from super class)

I'd rather not make SuperClass publicly visible... It is really just a utility class for this specific project (A.B).

It seems to me that SubClass should be able to see SuperClass, because package A.B.C is a subpackage of A.B... but this is not the case.

What would be the best way to resolve this issue? I don't think it makes sense to move everything in A.B.C up to A.B or move A.B down to A.B.C... mainly because there will probably be an A.B.D which inherits from stuff in A.B as well...

I'm a bit new to Java, so be nice :D (I'm a C++ and .NET guy)

© Stack Overflow or respective owner

Related posts about java

Related posts about packages