Possible Duplicate:
Why is the Java main method static?
What’s the reason of main method to be static? Why isn’t just public void main(String[] args)? I think I understand what static means, but I see no reason to be it here. Thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
We declare, main method in java as : public static void main(String args[])
static : main is the entry point of a class. In java everything is written in a class.Now when you run java on command prompt, loader will load the class and jvm will search the main method to enter into the class. so making the main() as static, will make jvm access it directly without creating the instance.
If main method were not declared static than JVM has to create instance of main Class and since constructor can be overloaded and can have arguments there would not be any certain and consistent way for JVM to find main method in Java.