Whenever any member is declared as static, it can be used
before any of its object is created, just by using class name. Hence static
members are used just by using class name. When JVM calls main(), it does not
have any instance of class having main() method. So this main() method is
called as classname.main().
JVM needs classname to call main() method. How does JVM know
what is your classname ?. When java program is compiled as javac filename.java,
(filename is same as class name containing main() method) JVM knows your
classname using which it calls main().
So file name is same as class name containing main method in java.
No comments:
Post a Comment