The Modifier class provides
RFAZHE7YNFV8
static
methods and constants to decode class and member access modifiers. The sets of modifiers are represented as integers with distinct bit positions representing different modifiers.
RFAZHE7YNFV8
Modifier | Used on | Meaning |
abstract | class interface method |
Contains unimplemented methods and cannot be instantiated. All interfaces are abstract. Optional in declarations No body, only signature. The enclosing class is abstract |
final | class method field variable |
Cannot be subclassed Cannot be overridden and dynamically looked up Cannot change its value. static final fields are compile-time constants. Cannot change its value. |
native | method | Platform-dependent. No body, only signature |
none(package) | class interface member |
Accessible only in its package Accessible only in its package Accessible only in its package |
private | member | Accessible only in its class(which defins it). |
protected | member | Accessible only within its package and its subclasses |
public | class interface member |
Accessible anywhere Accessible anywhere Accessible anywhere its class is. |
strictfp | class method |
All methods in the class are implicitly strictfp. All floating-point computation done is strictly conforms to the IEEE 754 standard. All values including intermediate results must be expressed as IEEE float or double values. It is rarely used. |
static | class method field initializer |
Make an inner class top-level class A class method, invoked through the class name. A class field, invoked through the class name one instance, regardless of class instances created. Run when the class is loaded, rather than when an instance is created. |
synchronized | method | 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 | Not be serialized with the object, used with object serializations. |
volatile | field | Accessible by unsynchronized threads, very rarely used. |
All Possible Combinations of Features and Modifiers
Modifier | Class | Variable | Method | Constructor |
public | yes | yes | yes | yes |
protected | no | yes | yes | yes |
none or package or default | yes | yes | yes | yes |
private | no | yes | yes | yes |
final | yes | yes | yes | no |
abstract | yes | no | yes | no |
static | no | yes | yes | no |
native | no | no | yes | no |
transient | no | yes | no | no |
volatile | no | yes | no | no |
synchronized | no | no | yes | no |
strictfp | yes | no | yes | yes |
Get More Java Posts : http://www.code2learn.com/search/label/java