+ 1
Why we use static in java?
While writing any java program....why we write...public static void main(String args[]){}
1 Respuesta
+ 4
Because we don't want to share main method with class objects.
If main method was not declared as static it would be declared as non-static by default, non-static method are able to get called by class objects.
We don't want the main method to get called by objects.
Even though we didn't call main by objects, declaring the method as non-static would waste recourses for method to be prepared to get called by class objects, which won't be done.