0
Why is the main method declared as "static" in java?
2 ответов
+ 2
This is neccesary because main() is called by the JVM before any objects are made. Since it is static it can be directly invoked via the class. Similarly, we use static sometime for user defined methods so that we need not to make objects. void indicates that the main() method being declared does not return a value.
+ 1
When you use static keyword for function and variables. You don't need to create object to access variable or function. like
class_name.function_name