The public static void main
method is the entry point for executing a Java program. It is the means by which you create a main method within the Java application. The public
keyword is an access modifier that specifies from where and who can access the method. Making the main()
method public makes it globally available. It is made public so that JVM can invoke it from outside the class as it is not present in the current class. The static
keyword is used to make the method a class-related method. The main()
method is static so that JVM can invoke it without instantiating the class. This also saves the unnecessary wastage of memory which would have been used by the object declared only for calling the main()
method by the JVM. The void
keyword is used to specify that the method doesnt return anything. As the main()
method doesn't return anything, its return type is void
. Finally, String[] args
is a parameter that accepts String type arguments. It allows us to pass arguments through the terminal and it stores these arguments.