What is java main method and how to use it

The main method

All Java programs begin the execution of code by calling the main method. Note that, the main method of java is case sensitive. So Main (starting with the capital letter) has different meaning in the Java application.

The main is the method of Java which is the mandatory part of any Java application.

See the example below of how to use the main method.

Example of using the main method

As you can see, the java main method is used inside the hello_world class.

As you run this code in the eclipse or other IDE the output will be:

Hello World


Also see – System.out.println

Was this article helpful?

Related Articles

Leave A Comment?