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









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
main method
main() method
Can a method inside a Interface be declared as final?
Can a method inside a Interface be declared as final?
Main method overloading
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?
ModuleNotFoundError: No module named 'static3'
ModuleNotFoundError: No module named 'staticx'
When is java main method called?
ModuleNotFoundError: No module named 'statico'
ModuleNotFoundError: No module named 'statico'
Why servletcontainer can,t call the Init() method ?
Why we are writting public static void main(String args[])?
What is the first argument of the String array in main() method?
ModuleNotFoundError: No module named 'statick'
ModuleNotFoundError: No module named 'statick'
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
HttpServlet is declared abstract
ModuleNotFoundError: No module named 'Hatak_Statics'
Accessing non-static members through the main method in Java.
JAVA what is different between static block and public static void main(String a[]) method
ModuleNotFoundError: No module named 'statick-fortify'
ModuleNotFoundError: No module named 'statick-md'
ModuleNotFoundError: No module named 'statick-tex'
ModuleNotFoundError: No module named 'statick-web'
ModuleNotFoundError: No module named 'statick-fortify'
ModuleNotFoundError: No module named 'statick-md'
ModuleNotFoundError: No module named 'statick-tex'
ModuleNotFoundError: No module named 'statick-web'

Ads