What Is Public Static Void Main Method in Java?



For stand one java program,the class name should be same as file name. we will get a compilation error if otherwise.The class should contain a main() method with the given signature:

public static void main(String[] args){}
 
Conceptually every java program must include a main() method to run independently.main() is the starting point or triggering point for interpreter to begin execution.A java program can have n-numbers of classes but only one of them include  a main() method to initiate the execution.

public-> is available for the world to use. check this link for more.
String[] args->It declares a parameter name args of type String array.The argument to the main is an array of String objects.In IDE mode of development,they will never be used in general,but they hold the arguments invoked on the command line.
Static:Static keyword declares this method /variable as one that belongs to the entire class and not part of any objects of the class. The main() method must always be declared as static since the interpreter uses this method before any objects are created.
void-->this modifier declares that main() method does not return any value. 
What Is Public Static Void Main Method in Java? What Is Public Static Void Main Method in Java? Reviewed by Animesh Chatterjee on November 25, 2018 Rating: 5

No comments:

Powered by Blogger.