Online visitors

People learning around the world

Online

—

Visitors exploring W3Schools

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    Java Modifier

    Java Programming Tutorials


    Access control modifier and non-access modifier are two types of modifiers in Java.

    Access control modifier

    There are four access modifiers available in Java, used to set access levels for classes, variable methods and constructor.

    • Scope only inside the same package (default)
    • Scope is visible to world (public)
    • Scope of the package and all subclasses (protected)
    • Scope only within the classes only (private)

    Non-Access modifier

    There are five non-access modifiers available in Java, used to achieve many other functionalities.

    • Modifier to finalizing the implementations of classes, methods, and variables (final)

    Example:

    class Phone
    {
     final int PRICE_MIN = 999;
     final int PRICE_MAX = 5600;    //final variable
     
     final void display()   //final method
     {
      System.out.println("Min Price is" + PRICE_MIN);
      System.out.println("Max Price is" + PRICE_MAX );
     }
    }
    • Modifier to create class methods and variables (static)

    Example:

    class Programming {
      public static void main(String[] args) {
        display();
      }
     
      static void display() {
        System.out.println("I love to programming in Java.");
      }
    }
    • Modifier for creating abstract classes and methods (abstract)
    • Modifiers for use in threads (synchronized and volatile)


    Found This Page Useful? Share It!
    Get the Latest Tutorials and Updates
    Join us on Telegram

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.