Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Classes and class members (classes, interfaces, fields and methods) are subject to access control. The access is indicated by an access modifier: public, protected, private, or the absence of an access modifier (the default access). A simplified view of the access control rules is summarized in the table below. An 'x' conveys that the particular access is permitted from within that domain.

Access Specifier

class

package

sub-classpackage

world

private

x

 

 

 

protectednone

x

x*x

 

 

defaultprotected

x

x**

x*

 

public

x

x

x

x

*For referencing protected members, the accessing class has to be a sub-class in any (possibly different) package or should also be in the same package.**Default members can be referenced only within the same package.

Classes and class members should be given the minimum access possible so that malicious code has the least chance to manipulate the system.

...