what is meaning of public static void main(string[] args)

why the declaration is standard for main method

  • Nikhil Dubba
  • Nikhil Dubba
  • |
  • 14 Jun
  • |
  • 40922 Views
  • |
  • 23 Answers

text limit upto 4000

  • 11

    Let's split it and understand one by one.
    1. public- Here public is an access specifier which allows thhe main method to be accessble everywhere.
    2. static- static helps main method to get loaded without getting alled by any instance/object.
    3. void- void clarifies that the main method will not return any value.
    4. main- It's the name of the method.
    5. String[] args- Here we are defining a String array to pass arguments at command line. args is the variable name of the String array. It can be changed to anything such as String [] a.

    Hope this helps...
     

    • Voted By:
    • Sayantan ,
    • Shahjad ,
    • Neha ,
    • Tulabandu ,
    • Saikiran ,
    • Umang ,
    • Indhu ,
    • Digvijay ,
    • Yogesh ,
    • Sohel

  • 1

    i can write main method like this static final synchronised strictfp void main(String... Shubham)

    • Voted By:
    • Ajinkya

  • 1

    public - it is access specifier means from every where we can access it
    static - access modifier means we can call this method directly using class name without creating an object of it
    void -  its the return type
    main - method name
    string [] args - in java accept only string type of argument and stores it in a string 
    you can run the java program when you declared this method. program will start main method.

    • Voted By:
    • Sayantan

  • 1

    Static means it will execute first . IT will compile with any static method but does not run untill JVM find main with string array argument .

    • Voted By:
    • Nikhil

  • 1

    public means that we can access main from any location. here 
    static means that there is only one copy of the main function is available.
    void main(String []q) main function can take argument and the type of argument is string array

    • Voted By:
    • Nikhil

  • 0

    it's a standard method signature given by JVM to start execution point of a program or to mark as a starting point. each of the method keyword is having special purpose.


  • 0

    Public is access specifier, go check it on geeksforgeeks. Static makes main method to execute everytime as it is a Static block. Void clarifies return type main is the mandatory function after java 6. String args take any command line arguments passed.


  • 0

    Java only starts running a program with the specific public static void main(String[] args) signature and one can think of a signature like their own name - it's how Java can tell the difference between someone else's main() and the one true main()
    Public: It is an access specifier which allow objects and method to get access from anywhere.
    Static:-  If the main method were not declared static than JVM has to create an instance of main class since the main method is static Java virtual Machine can call it without creating any instance of a class which contains the main method
    Void:- Main method will not return any value
    Main:- its the current name of executing method
    String:- Its means the value which will be sent from command line argument will be the type of String class.
    args[]:- It helps to send argument in the form of an array by knowing their locations eg:- 0,1,2..

     


  • 0

    Every program has to a main method, in where a program will start. That's why we have to declear a main method.


  • 0

    Main is the method which is the very first method that compiler executes in a program and the VOID is the return type for this method which return the specific value after executing the method void in this case (You can other return type too like -int which will return a integer value ). STATIC is for allocating a fix memory for this main method until its running period and PUBLIC is the access specifier which tells that this method can be used outside the class too (for the convenience of compiler). So all those keywords has meaning indicating to some specific task.


  • 0

    public - Access Specifier static - keyword void - the method does not return any value .


  • 0

    public : it is a access specifier that means it will be accessed by publically. static : it is access modifier that means when the java program is load then it will create the space in memory automatically. void : it is a return type i.e it does not return any value. main() : it is a method or a function name. string args[] : its a command line argument it is a collection of variables in the string format.


  • 0

    The syntax "public static void main(String args[]) " is very strict and if you perform any changes to this then it will return a "runtime exceptions" such as "No such method error: main" In this syntax:- public:JVM can access your main method from anywhere, static:without creating instances or objects to your class you still want your JVM to access, void:main method will not return any value back to JVM, main:main method configured with JVM, args:command line arguments. Instead of "args" we can replace with valid java identifier such as flower,abc,sweet... etc. And also instead of "(String args[])" we can replace with "var args main(String... args)"


  • 0

    public- It is an access specifier.It specifies that main function can be access publically. static- when the JVM call the main function it does not have an object that is why it is declared with the static keyword. void- It does not return value. main- Name of function. string args[]-It accept the string arguments.


  • 0

    Public means this method can be called from any where and static means JVM makes only one copy of this function and that must belong to one object and main is the name of function because it is a start of program and string means to a class and args is a array and we can print that array


  • 0

    jre calls main method without creating object..so in static we does not create object so we use static always in main method...jre visible only public other than that jre doesnt not support..command line aruguments are string type


  • 0

    "public static void main (String args[])" is the function which jvm used to find for executing the program.
    1.Here, public word is a access specifier which allows user to acces this function from anywhere.public specifier has the least restriction in terms of accessing the methods.Other acces apecifier are private,protected and default.
    2.static is a keyword of java.It allows user to acces the method or variable or block to access it without having any instance of that method/variable or block.Static denotes it is more related to class instead of the method itself.
    If you have not mentioned this keyword in main method ,u have to make a instance of that method to access it with help of "new " keyword.
    3.void is also a keyword of java.It means empty in english dictionary.As the name suugets ,it is return type of the main method.Other return types are mostly primitive data types like int,float,double.char,String etc.But main method only uses  void return type in java as it does not return anything.If You use any other return type,you will get compile type error.
    4.main is the method name .This is defined in thew codes of jvm.U cannot alter it because it is hard coded .If You want to edit the name of the main method,u have to deal with the code of jvm.
    5.String[] is the one dimension array of type String.It provides user with the facility to pass the arguments at the command prompt.If you donot pass any argument in command args then it will assume null by default.U can also var arg method instead of String args method .Var args array is kind of superset of array.

    Hope ,this might help you a bit.

    This is Standard because oracle programmers want it that way.
     
     


  • 0

    Main method is the starting point from where program execution start so that it should be public means it can be accessible from everywhere. Static means the memory allocated to it should not change in same execution time only one instance is created for main memory. void means main method should not return anything after completion of execution. main is the name of method and it has the String type array arguments.


  • 0

    Main method is the starting point from where program execution start so that it should be public means it can be accessible from everywhere. Static means the memory allocated to it should not change in same execution time only one instance is created for main memory. void means main method should not return anything after completion of execution. main is the name of method and it has the String type array arguments.


  • 0

    public means it main method should access everywhere in the program.
    Static means it should execute at the time of class loading.
    Void means main dosent return any value.
    String args[]=java accept all the value in the form of string.


Did Not Get The Answer? 
Contact people of Talent-Core Java directly from here