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 >>

11 Comments public static void main(string args[]) Explanation

  1. Jay

    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).

    1. naresh

      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

  2. Priyokumar

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

    1. J Singh


      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

Your email address will not be published. Required fields are marked *