| Modifier | C | F | M | L | Description | |
|---|---|---|---|---|---|---|
|
Scope (or access) Modifiers |
private | C | F | M | The scope is the enclosing class. (It is possible to nest one class in another.) | |
| (no scope modifier) | C | F | M | Commonly referred to as package-private, the scope is all classes in the enclosing (current) package. | ||
| protected | F | M | The scope is the enclosing package (just as with package-private) plus any classes that extend the enclosing class. | |||
| public | C | F | M | The scope is the entire program (all classes). | ||
| Other Modifiers |
static | C | F | M | The methods or properties become members of the enclosing
class object, not of instance objects of that class. |
|
| final | C | F | M | L | 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 | M | 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.
(As of 2020, all CPUs used in standard computers support the
SSE2 hardware extension, which means they support
IEEE-754.
Thus, strictfp is no longer useful and as of Java 17 you will
get compiler warnings if you use this modifier
or the StrictMath class.)
|
||||
| abstract | C | M | abstract classes may contain abstract
methods, which must be over-ridden in extended classes. |
|||
| volatile | F | Ignore any local cache and fetch (and write) the variable directly from (and to) RAM. Useful in multi-threaded applications. | ||||
| synchronized | M | 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 | F | 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 | M | 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: | ||||||
|---|---|---|---|---|---|---|
| The letters in the third column indicate to what the modifier may be applied: | ||||||
|