Java Language Visibility (controlling access to members of a class) Summary of Class Member Access Modifiers


Access ModifierVisibilityInheritance
PrivateClass onlyCan't be inherited
No modifier / PackageIn packageAvailable if subclass in package
ProtectedIn packageAvailable in subclass
PublicEverywhereAvailable in subclass

There was once a private protected (both keywords at once) modifier that could be applied to methods or variables to make them accessible from a subclass outside the package, but make them private to the classes in that package. However, this was removed in Java 1.0's release.