Skip to main content

Access Specifiers

Learn Access Specifiers (Java Basics, Java) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

1. Introduction An access specifier (access modifier) is a keyword that decides who can see and use a class , field, method or constructor : private (same class only), default with no keyword (same package), protected (same package plus subclasses anywhere) and public (everywhere). The compiler checks them, and since Java 9 the module system adds a second gate so a public type in a non-exported package is unreachable from other modules.

More lessons in Java Basics