Java - public static void main(String args[ ]) - Explanation
public static void main(String[] args) { /*Your Code*/ }
public :
It is an Access modifier , public means everyone can access it. That means it's in global scope. As, main method is called by JVM (Java Virtual Machine) , which is actually out of the project scope, the access specifier of this method is public.
static :
Java environment should be able to call this method without creating an instance of the class , so this method must be declared as static. so here static is a keyword which is when associated with a method, makes it a class related method.
void:
The return type of this method is void means there's no return value, void here is a keyword to specify that this method returns nothing.
main( ) :
The name of the method, main because it's the main method from where the program starts .
Note: main is not a keyword
String args[] :
Arguments to this method. This method must be given an array of Strings, and the array will be called 'args'. The main method is called only if it’s formal parameter matches that of an array of Strings.
Recommended Posts
Core Java Important Questions Part 1
Core Java Important Questions Part 2
Core Java Important Questions Part 3
Core Java Important Questions Part 4
Core Java Important Questions Part 5
Core Java Important Questions Part 6
Core Java Important Questions Part 7
Core Java Important Questions Part 8
Core Java Important Questions Part 9
Core Java Important Questions Part 10
Java Collections Interview Questions Part 1
Java Collections Interview Questions Part 2
If you are have any doubts join the discussions below , our moderators will clarify your doubts .