Static Methods in Java


Static methods belong to the class rather than any object instance and can be called without an object.

Source Code

class MyClass {
    static void staticMethod() {
        System.out.println("Static methods can be called without creating an object");
    }
}
public static void main(String[] args) {
    MyClass.staticMethod();
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments