what is public static void main

what is public static void main

1 year ago 82
Nature

In Java, `public static void main(String. The main method must be defined within a class because everything comes inside a class in Java. The parts of the main method are:

  • public: It means that you can call this method from outside of the class you are currently in. This is necessary because this method is being called by the Java runtime system which is not located in your current class.

  • static: When the JVM makes a call to the main method, there is no object existing for the class being called, therefore it has to have a static method to allow invocation from the class.

  • void: It is the return type of the main method, which signifies that the method doesnt return anything.

  • **String.

The `public static void main(String.

Read Entire Article