In this tutorial, you’ll understand public static void main(string args[]) in java programming
// A Java program to print "Hello World"
public class Hello {
public static void main(String args[])
{
System.out.println("Hello World");
}
}
Code language: PHP (php)
In the above application example, we are using the public static void main. Each word has a different meaning and purpose.
Table of Contents
Public
It is an Access Modifier, which defines who can access this Method. Public means that this Method will be accessible by any Class(If other Classes can access this Class.).
Static
Static is a keyword that identifies the class-related thing. It means the given Method or variable is not instance-related but Class related. It can be accessed without creating the instance of a Class.
Void
It is used to define the Return Type of the Method. It defines what the method can return. Void means the Method will not return any value.
main
Main is the name of the Method. This Method name is searched by JVM as a starting point for an application with a particular signature only.
String args[] / String… args
It is the parameter to the main method. The argument name could be anything. You can either use String array (String args[]) or var args variable of String type. Both will work the same way.