Skip to content

Latest commit

 

History

History
22 lines (17 loc) · 524 Bytes

package_private_methods.md

File metadata and controls

22 lines (17 loc) · 524 Bytes

Package-Private Methods

If a method is neither public or private then it can be used only by code in the same package.

We call these methods "package-private" because they are "private" to code outside the package.

package village;

public class Villager {
    void isNotVisible() {
        System.out.println("""
            This method can be called from code in the 'village'
            package, but not from other packages.
            """);
    }
}

Which again applies to static methods as well.