public class First {
public static void main(String[] args) {
System.out.println("Hello World!!!");
}
}
public
: is an access modifier, which controls the visibility of the method, here the public method main can be accessed by code outside the class in which it is declared. In this case main must be declaredpublic
, since it must be called by code outside of its class when the program starts.static
: It allows main method to be called without creating an instance of the class in which the main method resides. This is necessary since main is called by the jvm before any objects are made.void
: It is a return type and simply indicates to the compiler that it does not return any value.main
: it is the method name and is the entrypoint for executing programs by jvm. Programs without main method still gets compiled but does not run as it cannot find the main method. Note that java is case-sensitive and thus Main is different from main.String[] args
: It is the parameter named args, which holds the Array of Strings. In case of main method args consists of command line arguments which are provided while executing the program from the command line. Even though we may or may not provide command line arguments we must include the parameter in the function signature.{
}
are used to enclose the body of a method.{
signals the start of the method body and}
signals the end of the method body.