Java Reference
In-Depth Information
16.3. The Modifier Class
The Modifier class defines int constants for all non-annotation modifiers:
ABSTRACT , FINAL , INTERFACE , NATIVE , PRIVATE , PROTECTED , PUBLIC , STATIC , STRICT ,
SYNCHRONIZED , TRANSIENT , and VOLATILE . For each constant there is a cor-
responding query method is Mod (intmodifiers) that returns TRue if modifier
mod is present in the specified value. For example, if a field is declared
public static final int OAK = 0;
the value returned by its Field object's getModifiers method would be
Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL
The strictfp modifier is reflected by the constant STRICT . If code or a
class is to be evaluated in strict floating point (see " Strict and Non-Strict
Floating-Point Arithmetic " on page 203 ) , the modifiers for the method,
class, or interface will include the STRICT flag.
The query methods can be used to ask questions in a more symbolic
fashion. For example, the expression
Modifier.isPrivate(field.getModifiers())
is equivalent to the more opaque expression
(field.getModifiers() & Modifier.PRIVATE) != 0
 
Search WWH ::




Custom Search