Why is the main method declared static?

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

Ads









Related Tutorials/Questions & Answers:
Why is the main method declared static?
What if the main() method is declared as private?
Advertisements
Can a main method be declared final?
Should a main method be compulsorily declared in all java classes?
Why we should use string args[] in main method in java?
main method
main method
why not float main?
why not float main?
main() method
Can a method inside a Interface be declared as final?
Can a method inside a Interface be declared as final?
why get method is used?
What is the return type of the main method?
java sleep in main method
java sleep in main method
What is the arguement of main method?
Can a main method be overloaded?
Is main method compulsory in Java?
When is java main method called?
Why servletcontainer can,t call the Init() method ?
What is the first argument of the String array in main() method?
Why we are writting public static void main(String args[])?
ModuleNotFoundError: No module named 'static3'
ModuleNotFoundError: No module named 'staticx'
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method

Ads