Java: Subpackage visibility

encapsulationjavapackagevisibility

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?

Best Answer

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