The main method

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 public indicates that the method can be invoked from everywhere;
  • the keyword static indicates the method can be invoked without creating an instance of the class;
  • the keyword void indicates the method doesn’t return any value;
  • the array variable args contains arguments entered at the command line, the array is empty if there are no arguments.

Leave a Reply

Your email address will not be published.

ANOTE.DEV