+ 1

Why is the main method made static?

17th Jan 2020, 8:33 AM
Pranita
Pranita - avatar
2 Respostas
+ 3
Because it need to be called without making an instance of the class.
17th Jan 2020, 9:34 AM
Felipe Santa-Cruz
Felipe Santa-Cruz - avatar
+ 3
The main method is the entry point of execution in java. Hence it should available to JVM for execution before any objects to be created.. If it not static, then we need an object to call that method but objects are created at run time only.. So there raises an confusion for JVM.. Edit: For some more clarity.. See this link 5th point... https://www.google.com/amp/s/www.geeksforgeeks.org/understanding-static-in-public-static-void-main-in-java/amp/
17th Jan 2020, 10:58 AM
Jayakrishna 🇮🇳