1 |
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
|
2 |
These modifiers are also used for access control to the instance variables and methods.
|
3 |
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).
|