+ 1
Why main method is static?
4 Respuestas
+ 10
In Java, everything must be written in a class. In order to call a method like main() from a class, you either need to instantiate an object of that class, or it must be made static.
Considering main() is the first method that's run, and no objects can be made before then, it must be made static.
If you don't understand what that means yet, then don't worry about it.
+ 5
Not if you're inside the class in question.
0
but a static method we should call it by the name of the class??
0
ok, thank you