0
why main method is static?
Classes are introduced into the Java environment when they are referenced by name in a class that is already running. There is a bit of magic that goes on to get the first class running (which is why you have to declare the main() method as static, taking a string array as an argument), but once that class is running, future attempts at loading classes are done by the class loader. if the reason is correct then can u explain?
1 Resposta
+ 19
The main method must be public so it can be found by the JVM when the class is loaded. Similarly, it must be static so that it can be called after loading the class, without having to create an instance of it.