Modifier | Used on | Meaning |
abstract | class |
The class contains unimplemented methods and cannot be
instantiated.
|
| interface |
All interfaces are abstract. The modifier is
optional in interface declarations.
|
abstract | method |
No body is provided for the method; it is provided by a
subclass. The signature is followed by a semicolon. The
enclosing class must also be abstract.
|
final | class |
The class cannot be subclassed.
|
| method |
The method cannot be overridden (and is not subject to
dynamic method lookup).
|
| field |
The field cannot have its value changed. static
final fields are compile-time constants.
|
| variable |
A local variable, method parameter,
or exception parameter cannot have its value changed
( Java 1.1 and later). Useful with local classes.
|
native | method |
The method is implemented in some
platform-dependent way (often in C). No body is provided; the signature
is followed by a semicolon.
|
none (package) | class |
A non-public class is accessible only
in its package.
|
| interface |
A non-public interface is accessible
only in its package.
|
| member |
A member that is not private,
protected, or
public has package visibility and is
accessible only within its package.
|
private | member |
The member is accessible only within the class that
defines it.
|
protected | member |
The member is accessible only within the package in which it
is defined and within subclasses.
|
public | class |
The class is accessible anywhere its package is.
|
| interface |
The interface is accessible anywhere its package is.
|
| member |
The member is accessible anywhere its class is.
|
strictfp | class |
All methods of the class are implicitly
strictfp ( Java 1.2 and later).
|
strictfp | method |
All floating-point computation done by the method must be
performed in a way that strictly conforms to the IEEE 754
standard. In particular, all values, including
intermediate results, must be expressed as IEEE
float or double
values and cannot take advantage of any extra precision
or range offered by native platform floating-point formats
or hardware ( Java 1.2 and later). This modifier is rarely used.
|
static | class |
An inner class declared
static is
a top-level class, not associated with a member of the
containing class (Java 1.1 and later).
|
| method |
A static method is a class method. It is not passed an implicit this
object reference. It can be invoked through the class name.
|
| field |
A static field is a class field. There is only one instance of the field, regardless of
the number of class instances created. It can be
accessed through the class name.
|
| initializer |
The initializer is run when the class is loaded, rather than
when an instance is created.
|
synchronized | method |
The method makes non-atomic modifications to the class
or instance, so care must be taken to ensure that two
threads cannot modify the class or instance at the same
time. For a static method, a lock
for the class is acquired before executing the
method. For a non-static method, a lock for
the specific object instance is acquired.
|
transient | field |
The field is not part of the persistent state of the
object and should not be serialized with the object. Used with object serialization; see
java.io.ObjectOutputStream.
|
volatile | field |
The field can be accessed by unsynchronized threads, so
certain optimizations must not be performed on it. This
modifier can sometimes be used as an alternative to
synchronized. This modifier is very
rarely used.
|