JVM is the program written by javasoft
people. If we do not write "public" keyword in front of the main then it will not
be available to JVM and Main method will not be executed.
Only after calling the main method an
object is created but to create an object we should first execute main method.
,So, We should call the main method with out creating the Object and such
methods are called as static methods.
Static method is the one which is
called without creating an object but calling with the classname.method().So
that is the reason why main method is declared as static and JVM calls the main
method as classname.main()
since main does not written any thing we specify "void" keyword.
also,we should pass String type array for the main method.
No comments:
Post a Comment