Java - main( ) Method

Syntax

The main() method declaration is as follows:

public static void main(String[] args) {
    // Method body goes here
}

Two modifiers, public and static, are used in the declaration of the main() method.

You run a Java application by passing a class name to the java command.

For example, you would use the following command to run the MethodTypeTest class:

java MethodTypeTest

Related Topics