What is the meaning of public static void main (args [] Strings ) in java

What is the meaning of public static void main (args [] Strings ) in java

Meaning of public static void main ( String [] args ) in java.

In Java Programs main() is the most important method or you can say that none of the java programs run without the this method.

 class abloggerdude


                            public static void main(String[] args) {

                                    System.out.println(“This is an blogging site”);



            output:- This is an blogging site


public is an Access modifier, which says about who and from where can access this methods.

what happened when we made any method public?

 Ans :- Making any method public means this method is available globally. which means you can access this method   from anywhere.

why main() method made public in java?

Ans:- mian()  method made public in java so that JVM(java virtual machine) will be  able to  made call from outside of the class.

what happened when you made main method private?         

 Ans:- when you made main()  method private then it is not accessible to the JVM so that it shows the error main method not found exception.

 class Abloggerdude {

     private static void main(String[] args) {

              System.out.println(“Abloggerdude is an blogging sites”);



Error:- Main method not found in class please define the main method as:- public static void main.



  • static is an keyword that shows the class level things means if you define any method or variable as an static method or static variable then you need not to create the instance of the class to call these method or variable.


class Abloggerdude{

 int rollno. ;            //   (normal or instance variable)

String writerName;

static String field=”Poet”;       //Variable define as static

Student(int r, String n){

rollno. = r;

writerName = n;


//methos that display the value of variables.

void display (){

System.out.println(rollno.+” “+writerName+” “+field);



public class TestStatic1{

public static void main(String args[]){

Abloggerdude s1 = new Abloggerdude (1212,”Shivam”);

Abloggerdude s2 = new Abloggerdude (121212,”Shivansh”);





  • As you seen in the above example we didn’t use any instance of class to call
    the static variable but for calling for normal variable we should need a
    instance of class for calling it.
    basically we use static keyword when we want to make the variable independent
    to creating the instance.

  Why main function always be static ?

Ans:- This is because compiler can call the main method directly without any creation of the objects or you can say that before the object creation.  As we know  main method is entry point of the program if we not use the static keyword then compiler never compile the main method and program never run and shows the error.



    Why main method is always void ?

Ans:-  First thing void is an keyword which specify that the function doesn’t return anything. so as we know main () method doesn’t  return any things that’s why main method always written as void.



      Why java main () method name is ‘main’ ?

Ans:- Sometimes interviewer asks this question and student get confused in this simple question .the simple answer of this question is  ‘main’ is  the name of java main method which is define in java programing language  so  JVM  (java virtual machine ) get to know the starting point of the programs and execute it.

class  Abloggerdude {

                                    int rollno.=101;

                                    public static void mymain( String [] args) {   //here we change the main ()                                                                                                                                     // name  as mymain() 

                                     Abloggedude  dude = new Abloggerdude();




 Error:- This program shows error main method not found.



String [] args

Basically this store java command line arguments or  single argument of type string array.      here ‘args’  is an String name of array and you can use instead of ‘args’ without any error.


  What is ‘args’ in String []  args ?

Ans:-args is a name of String of type array.


Above  we discuss the Meaning of public static void main ( String [] args ) in java and i think we cover all the interview question related public static void main ( String [] args ) .

I hope from this post that you have understood why public static void main is use in main method in java.

You can also read:-

If you like this article, then share it with all your friends on social media so that someone else can get help by you .



0 thoughts on

What is the meaning of public static void main (args [] Strings ) in java

  • cialis acheter in zwolle

    Very good post! We will be linking to this great post on our website. Keep up the good writing.| Madalena Oberon Roumell

Leave a Reply

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

Reading is essential for those who seek to rise above the ordinary.

Discover Abloggerdude

Welcome to Abloggerdude, an author oriented theme.
A place where words matter. Discover without further ado our countless community stories.

Build great relations

Explore all the content form Abloggerdude community network. Forums, Groups, Members, Posts, Social Wall and many more. You can never get tired of it!

Become a member

Get unlimited access to the best articles on Abloggerdude and support our  lovely authors.

© 2020, Abloggerdude
Skip to toolbar