Definition:
Every Java application must have a main method. It’s the starting point for the execution of the code in the application. Its method signature is:
public static void main(String[] args)
The args parameter is a String array that contains any command-line arguments used to run the application.
Examples:
The program below has a main method that prints out any command-line arguments passed when running the code:
import java.util.Arrays; public class PrintArguments { public static void main(String[] args) { String commandlineArgs = Arrays.toString(args); //The Arrays.toString function encases the Strings //in the array with square brackets. if (commandlineArgs.equals("[]")) { System.out.println("There were no arguments."); } else { System.out.println("There command-line arguments were: " + commandlineArgs + "."); } } }

