Java: Subpackage visibility?

Nick Heiner picture Nick Heiner · Dec 27, 2009 · Viewed 63.4k times · Source

I have two packages in my project: odp.proj and odp.proj.test. There are certain methods that I want to be visible only to the classes in these two packages. How can I do this?

EDIT: If there is no concept of a subpackage in Java, is there any way around this? I have certain methods that I want to be available only to testers and other members of that package. Should I just throw everything into the same package? Use extensive reflection?

Answer

starblue picture starblue · Dec 27, 2009

You can't. In Java there is no concept of a subpackage, so odp.proj and odp.proj.test are completely separate packages.