O'Reilly logo

Java Quick Syntax Reference by Mikael Olsson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 15

image

Access Levels

There are four access levels available in Java. These are public, protected, private and package-private. Package-private cannot be explicitly declared by using a keyword. Instead, it is the default access level for every member in Java.

public    int myPublic;   // unrestricted accessprotected int myProtected;// package or subclass access          int myPackage;  // package accessprivate   int myPrivate;  // class access

Private access

The most restrictive access level is private. Members with this level can only be used inside of the enclosing (containing) class.

package mypackage;public class MyApp{   public    int ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required