There is a library, in it, for example, there is such a class:
public class SimpleObject { private object; public void setObject(Object object) { ... } public Object getObject() { ... } } Nearby, in a nearby package, is the ObjectHandler class, which accepts this object and, based on the result of the .getObject() method, does something.
It is necessary to make the user, having received or created a SimpleObject object, could not use the .getObject() method (so that the method for the user was something like private ), and the ObjectHandler class could see it.
How to do it?
This is necessary in order not to show the user unnecessary methods (and it is more convenient for him and safer for me). Now, to achieve this goal, we have to throw an object and its handler into one package (which looks a bit incomprehensible), and make the get method available within the package.