main method is the first method which get called automatically when the program executes.
there must be only one main in a java program which you want to execute.
in main method signature/prototype
public :
It is a access specifier which defines the scope of the method it must be public
static:
makes the method to be called with the class name as to run the program we use the class name. thats is the reason static is there in main method.
void:
void states that the main method doesnt return anything. and it must be void only.
main : it is a name of method.
(String[] args) : here args is an array of String class and it must be string class array only.
here instead of String[] args you can use varargs i.e String... args
main method cannot be override
main method can be overloaded.
No comments:
Post a Comment