The static keyword in java is used for memory management mainly. We can apply java static keyword with variables, methods, blocks and nested class. The static keyword belongs to the class than instance of the class. java static methods can be called without creating an object of class. Have we noticed why we write static keyword when defining main it's because program execution begins from main and no object has been created yet. Consider the example below of static methods.
class programming { public static void main(String[] args) { display(); }
static void display() { System.out.println("Java is my favorite programming language."); } }
Liked By
Write Answer
What is static method in java?
Join MindStick Community
You have need login or register for voting of answers or question.
Anonymous User
26-Mar-2015If you apply static keyword with any method, it is known as static method.
Anonymous User
26-Mar-2015