Java Modifier Types

Modifier Types

you add to those definitions to change their meanings. Java language has a wide variety of modifiers the following:

  • Access Control Modifiers
  • Non-Access Modifiers

Example:

public class className {
   // ...
}

private boolean myFlag;
static final double weeks = 12.5;
protected static final int BOXWIDTH = 52;

public static void main(String[] arguments) {
   // body of method
}

Access Control Modifiers:

  • Visible to the class only private.
  • Visible to the world (public).
  • Visible to the package and all subclasses (protected).

Non-Access Modifiers

following are the types of non-access modifiers:

  • The abstract modifier for creating abstract classes and methods.
  • The final modifier for finalizing the implementations of classes, methods, and variables.
  • The static modifier for creating class methods and variables
  • The synchronized and volatile modifiers, which are used for threads
Related Post