This question already has an answer here:
In Java, difference between package private, public, protected, and private
A class from a subpackage needs to access a class from a package one level up. So, I need to keep the target class as public. But I don't want that class to be accessed by any other class. What can I do?