+ 3
Why main method should be static?
3 Réponses
+ 9
Are you talking about Java? if yes: Because it's the starting point of your program and you want to start without creating an object first. "static" is exactly doing that. it makes the main method execute without to have to instantiate an object first.
+ 2
beacause of static its only one copy is created and all the methods packages classes access it
+ 2
Main method should be static because main method is class level method it is no way related to object, without existing object also jvm has to call this method and main method is no way related to any object that's why main method should be static. Jvm always search only main method because of prototype main method is defined in jvm that's why the search only main method.
I think its helpful..