java “public static void main(string args) “

Java “public static void main(string args) “

As We know that Java is a compiled and interpreted language. First code compilation has done in java and then this code converts into byte code format. And this byte code later interprets it into machine level language.

For the whole process, the compiler should start from somewhere for its conversion. So, that starting point is considered as the main method. So every program in java starts its execution from this point.

So, normally the execution directly starts with the main method, though it is written at the 100th line of the program. After that only other classes and methods get executed.

The meaning of all terms “public static void main(string args)” are as follows:

public: This is the access specifier of the method. It indicates that this method can be used in any class inside any package. Generally, there are private and protected types that are also available. These are having the limitations to be called on the objects.

Static: It is a particular type of method. Static methods can be called without the creation of the objects inside the class. In general, you can not call any method without an object. In Java, there is a rule that every method should be called on the object.

void: This means nothing. It has a significance that Java compiler isn’t interested in the return type of this method. As every method has a specific return type, so in this case, the main method does not return anything. Hence it returns nothing or in other words avoid it.

String [] args: This is the array of type string and its name is ‘args’. This can take the inputs from the command line in the string format. we can replace the array name with anything then also it works fine. i.e. String []xyz or String abc[] etc.