Java Program using static method


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


static void display() { }


Example: How to implement static method in Java

Run it Now
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