Why is the main method declared static?

Hi,

Why is the main method declared static?

thanks

View Answers

April 11, 2013 at 11:50 AM

Hi,

When we declare main() method in any Java class always has the same signature, and we declare public static void main(String args[]. The motive of it is that static in JVM can call it directly without creating any instance for the java class, where we declared it. Any static java method can be called without having to instantiate in the class that defines the static method.

For more visit http://www.roseindia.net/java/beginners/howtoaccessstaticmethod.shtml









Related Tutorials/Questions & Answers:
Advertisements