Java Coder
Why is the main method declared static?
1 Answer(s)      2 years ago
Posted in : Java Beginners

Hi,

Why is the main method declared static?

thanks

Advertisement
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