| Modifier |
Used with |
Description |
| abstract |
Classes
Interfaces
Methods |
Declares a Class or Method that is incomplete.
All Interfaces are implicitly abstract so the modifier is redundant.
A Class which has an abstract Method must be declared abstract.
|
| final |
Classes
Field variables
Methods
Method parameters
Local variables
|
Indicates a definition is complete and cannot be changed.
Classes may not be extended.
Field variables may not be modified once a value is assigned.
Methods cannot be overridden.
Required for Method parameters and Local variables if they are to be used by an Inner Class.
Note: A Class may not be both final and abstract.
|
| native |
Methods |
Indicates a platform-specific method written in another language.
Note: a method cannot be both native and abstract
|
| static |
Initializers
Methods
Variables
|
Indicates an initializer, method or variable belongs to a class vs an instance (object) of the class.
Static initializers are processed once, when the class is loaded.
Static methods are used to access static variables. They may not be used to access non-static variables unless they specify an instance of the class.
|
| synchronized |
Methods |
Indicates a method acquires a lock on an object before it executes.
Used to control access to objects shared by multiple threads.
|
| transient |
Variables |
Indicates the variable is not part of the permanent state of an object and may not be serialized (written to a stream). |
| volatile |
Variables |
Indicates a variable may be changed by more than one thread.
Each thread has it's own copy of a working variable. Volatile ensures the variable is compared to the master copy each time it is accessed.
|