which class the method "main" belongs to ? and how java behaves with the method "main" ?
Printable View
which class the method "main" belongs to ? and how java behaves with the method "main" ?
Please see multiple answers to your same question / cross-post in the Sun Java forums.
The method "main" belongs to every class which has one. There is nothing special about the main method. The only thing that sets the "main" method apart from any other static method, is that when say
[code]
java MyClass
[/class]
the jvm will attempt to invoke the static method main with a String[] as the argument. So, if that method does not exist, the JVM cannot start your program, but for all of that, it is still just another static method.