Java Program using the static method


In this program, You will learn how to implement a static method in java.


static void display() { 
   //statement
}

Example: How to implement a static method in java.

class Main {

    static int x = 10;

    static void display() {
        System.out.println("The value of x is :" + x);
    }

    public static void main(String args[]) {
        display();
    }
}

Output:

The value of x is :10