It allows the method to be called without creating an instance of the class.
Explanation:
In Java, the static keyword is used for:
Static Methods and Variables:
Methods: A static method belongs to the class rather than instances of the class. This means you can call the method directly on the class itself without needing to create an instance.
class Example {
static void staticMethod() {
System.out.println("Static method");
}
}
// Calling the static method without creating an instance
Example.staticMethod();