Access modifiers control which other code can use a class or its members. Java has four levels, from most to least restrictive:
private: visible only inside the same class.
No modifier, called package-private or default access: visible to any class in the same package.
protected: visible in the same package, and to subclasses in other packages.
public: visible from anywhere.
A top-level class can only be public or package-private.
Start with the most restrictive level that works, such as private fields behind public methods, so a class can change its internals without breaking callers.
Rewriting in plainer words…
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.