What are Java Modifiers?
Java classes, interfaces, and their members can be declared with one or more modifiers.They can be categorised as:
Class Modifiers :
ClassModifier: one of
public private(for inner classes) protected(for inner classes)
abstract static final strictfp
Any top level class can either be public or package private(no explicit modifier)
Field Modifiers
FieldModifier: one of
public protected private
static final transient volatile
Method Modifiers
MethodModifier: one of
public protected private abstract static
final synchronized native strictfp
Constructor Modifiers
ConstructorModifier: one of
public protected private
The following matrix of the all modifiers in Java shows which modifier maps to which element:-
Class Modifiers :
ClassModifier: one of
public private(for inner classes) protected(for inner classes)
abstract static final strictfp
Any top level class can either be public or package private(no explicit modifier)
Field Modifiers
FieldModifier: one of
public protected private
static final transient volatile
Method Modifiers
MethodModifier: one of
public protected private abstract static
final synchronized native strictfp
Constructor Modifiers
ConstructorModifier: one of
public protected private
The following matrix of the all modifiers in Java shows which modifier maps to which element:-
More on access specifiers..