Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Why is the main method declared static?
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Java Coder
Why is the main method declared static?
1 Answer(s)      a year and 7 months 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



Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com