Note: First of all, Java is a case-sensitive language so there is a difference between main and Main.
public is the access specifier. It is used because it can be accessed outside the class also as the main method is called by JVM(Java Virtual Machine) outside the class. So we have to use the keyword public.
If the method is static then we don’t have to make the object of the class. As the main method doesn’t belong to a particular object.
void means no return value. This means the main method will not return any value.
The ‘String’ is a predefined class. args is an array and you can change the name because it is a variable.
Ways to write the main method in Java:
public static void main(String args[])
public static void main(String tanmay[])
public static void main(String []args)
public static void main(String …args)
System.out.println();
This syntax is used to print the statement, value etc.
Here System is the predefined class and it is defined is the java.lang package.
out is an object and static field of the class and it is used with three keywords public static final.
System.out.print will print the text but the cursor will be on the same line so we use println because after printing the text the cursor should be on the next line.