why main method should always be static?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

why main method should always be static??

22nd Nov 2016, 5:45 AM
Monica Grace
Monica Grace - avatar
5 Answers
+ 3
When the JVM makes are call to the main method there is not object existing for the class being called therefore it has to have static method to allow invocation from class.
22nd Nov 2016, 6:53 AM
Simone Novaro
Simone Novaro - avatar
0
please give me more explanation...
27th Nov 2016, 1:35 PM
Monica Grace
Monica Grace - avatar
0
static can be run without any instance of a class.
27th Nov 2016, 2:32 PM
Carlo Palermo Mamuric
Carlo Palermo Mamuric - avatar
0
If you not define it as static, then u have to create an object for it, even without defining it as static you can do it, but should create an object for it.....
28th Nov 2016, 11:16 AM
Pavankumar V
Pavankumar V - avatar
0
give me specification with example
20th Dec 2016, 11:30 AM
Satya Jeet
Satya Jeet - avatar