0
Is it necessary to declare main method as static in java...what is the use of it...
why it is static,public static void main
2 odpowiedzi
+ 3
Yes it is, because the 'static' access modifier defines that a method, in this case main, to be a class' method, which means it can be executed/invoked without having to create an instance of the said class. If the static access modifier was omitted, the method is then defined as instance method, an instance must be created of the class, before an method within that instance can be invoked.
Hth, cmiiw
+ 1
understood,thanks