A static method belongs to the class rather than to any specific instance of the class. Static methods can be called without creating an object of the class.
Key Points about Static Methods:
public class StaticMethodExample {
// Static method
public static void printMessage() {
System.out.println("This is a static method.");
}
public static void main(String[] args) {
// Calling static method without creating an object
StaticMethodExample.printMessage();
}
}
This is a static method.