| Modifier | C | P | M | L | Description | |
|---|---|---|---|---|---|---|
|
Scope (or access) Modifiers |
private | • | • | • | The scope is the enclosing class. (It is possible to nest one class in another.) | |
| (no scope modifier) | • | • | • | Commonly referred to as package-private, the scope is all classes in the enclosing (current) package. | ||
| protected | • | • | The scope is the enclosing package (just as with package-private) plus any classes that extend the enclosing class. | |||
| public | • | • | • | The scope is the entire program (all classes). | ||
| Other Modifiers |
static | • | • | • | The methods or properties become members of the enclosing
class object, not of instance objects of that class. |
|
| final | • | • | • | • | This modifier means the item can't be modified.
For variables this makes them constants.
final methods can't be over-ridden.
final classes can't be extended. |
|
| strictfp | • | All floating point operations will be done according to the IEEE Floating-point standard, even if the floating-point hardware in the CPU doesn't meet the standard. | ||||
| abstract | • | • | abstract classes may contain abstract
methods, which must be over-ridden in extended classes. |
|||
| volatile | • | Ignore any local cache and fetch (and write) the variable directly from (and to) RAM. Useful in multi-threaded applications. | ||||
| synchronized | • | Used for multi-threading to prevent two threads
from executing the same block of code at the same time.
(synchrolized blocks are also allowed.) |
||||
| transient | • | Used for serialization when objects must be saved
in files (or sent across a network).
Any transient properties will not be saved (or sent). |
||||
| native | • | Used when implementing the JRE methods to allow the JVM to execute non-Java (usually C) code. Any such methods make a program non-portable. |
| Legend: | ||||||
|---|---|---|---|---|---|---|
| A bullet ("•") in a column indicates to what the modifier may be applied: | ||||||
|