The main method is the entry point for any application. The main method is the entry point for any application. It means that the execution of any program begins right here.
public class Main {
public static void main(String[] args) {
System.out.println("Hello World");
}
}Here is a class named Main. The class contains the main method for starting the program.
- the keyword
publicindicates that the method can be invoked from everywhere; - the keyword
staticindicates the method can be invoked without creating an instance of the class; - the keyword
voidindicates the method doesn’t return any value; - the array variable
argscontains arguments entered at the command line, the array is empty if there are no arguments.