Public Protected Private Modifiers in Java
Jan 8, 2021
Many Java developers are trying to understand the difference between access modifiers such as private, public, protected and no-modifier.
Table above shows everything needed however, I believe it is easier to remember the explanations below.
Private modifier, hides access from other classes within the package.
Public modifier, exposes access to every other classes independent of package level.
Protected modifier, works like public modifier, it only limits access to world (eg. out of project access)
No-modifier, restricts access from different packages.
You may want to check the official documentation here for more information.