Basic HTML version of Foils prepared June 5 99

Foil 48 Access control

From Java Language in the Computer Science Curriculum ADMI Tutorial Duluth Minnesota -- June 3 99. by Geoffrey C. Fox


The modifiers in the class head control how other classes can access this one:
  • public -- May be used by code outside the class package
  • private -- this class can only be used within current file
  • friendly(i.e. empty ClassModifier) -- class can be used only within current package (directory)
  • protected -- Only accessible to subclasses
These modifiers are also used for access control to the instance variables and methods.
There are other modifiers. For example, a static variable or method only has the same value for all instances of the class. A final variable cannot be assigned to (used for constants).



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Jun 5 1999