public static void main(string args[]) Explanation

This entry is part 9 of 33 in the series Core Java Course
In Above application we are using public static void main. Each word has different meaning and different purpose.

Public : It is an Access Modifier, which(AM) defines who can access this method(In Java World). Public means that this method will be accessible to any class(If other class can access this class.).

Static : Keyword which identifies the class related this. It means that this class is not instance related but class related. It can be accessed without creating the instance of Class.

Void : Return Type, It defined what this method can return. Which is void in this case it means that this method will not return any thing.

main: Name of the method. This method name is searched by JVM as starting point for an application.

String args[] :  Parameter to main method.

Series Navigation<< Java Reference VariableWrite Hello World Application Using Eclipse >>

About the author

J Singh

Main brain behind this blog/QnA site. She has written all these article as per her personal experience. She has published it mainly to help beginners. These articles might have some problems. So bear with her and let her know if you find any problem in any of the article.

8 Comments

  • String args[] : Parameter to main method…

    Please site how to use the main() with values given to parameters (like what the difference would be with (or without) these values).

    • If u dont use it shows error in execution….that y we r passing infinite arguments in String type…string is one.type of class ….so,first letter is capital

  • Why “String[] ags” is passed as parameter of main function and without passing this parameter what will happen?

    • HI,

      This is a standard which needs to follow if we want jvm to search it to execute it. There is no harm in removing this parameter from method but then that method will be treated as other java methods and it will not be directly called by JVM.

Leave a Comment