Java Reference
In-Depth Information
Other Java Modifiers
Figure E.3 summarizes the rest of the Java modifiers, which address a variety of
issues. Furthermore, a modifier has different effects on classes, interfaces, meth-
ods, and variables. Some modifiers cannot be used with certain constructs and
therefore are listed as not applicable (N/A).
The transient modifier is used to indicate data that need not be stored in
a persistent (serialized) object. That is, when an object is written to a serialized
stream, the object representation will include all data that is not specified as
transient.
Modifier
Class
Interface
Method
Variable
abstract
The class may con-
tain abstract meth-
ods. It cannot be
instantiated.
All interfaces are
inherently abstract.
The modifier is
optional.
No method body is
defined. The method
requires implementation
when inherited.
N/A
final
The class cannot be
used to drive new
classes.
N/A
The method cannot be
overridden.
The variable is a constant,
whose value cannot be
changed once initially set.
native
N/A
N/A
No method body is neces-
sary since implementation
is in another language.
N/A
static
N/A
N/A
Defines a class method. It
does not require an instan-
tiated object to be invoked.
It cannot reference non-
static methods or variables.
It is implicitly final.
Defines a class variable. It
does not require an instan-
tiated object to be refer-
enced. It is shared (com-
mon memory space) among
all instances of the class.
synchro-
nized
N/A
N/A
The execution of the
method is mutually exclu-
sive among all threads.
N/A
transient
The variable will not
be serialized.
The variable is changed
asynchronously. The
compiler should not
perform optimizations
on it.
N/A
N/A
N/A
volatile
N/A
N/A
N/A
FIGURE E.3 The rest of the Java modifiers
 
Search WWH ::




Custom Search