0
Why we should write static in the main method
Purpose of declaring it
2 Réponses
+ 3
Well, what is static?
We use static to indicate that the member is bound to the class rather than the instance of the class. So, it belongs to the class itself.
A benefit from this is, we don't have to create an object of our class in order to call the method. We can call the class instead, and since it's also public the compiler can do a simple search for the main method like so:
myClass.main(args);
0
static refers for the belongness of the method to the class not for object