Wednesday, December 6, 2006

public static void main(String args[])

Hi There

The first question for a novice Java Programmer would be-why is the signature of main method the way it is

1)public-- Because the main method is invoked by JVM (which is an outsider).So giving public access is very much important.
2)static--Becasue the main method should be invoked without instantiating the class which has the main method.
3)void--Because the return type of the method is null.
4)String args[]--To accept data from command line(command lin earguements).

No comments: