public static void main(String[] args) - DevDummy

Latest

Coding Hacks, Shared ...

Friday, October 13, 2017

public static void main(String[] args)


public static void main(String[]  args)

In Java, the execution of an application starts this method, with signature 'public static void main(String[]  args)'

It is also said to be the main execution point where the Java main thread start executing.

What does it mean ?

public  - Accessible from the out side of the class, It is required to get access to this method.

static - Class level access as no object is being created yet.
void - returns nothing while exiting from the application to the system which make sure the scope is destroyed on exit.

main - Fixed name defined to identify the entry point for JVM 

string[] args - String array as argument to the application

Why string[] args ?


arguments can be passed to the application via string[] args  on execution through the terminal in case if some data is needed for the application and it is optional.

public class App
{
    public static void main( String[] args )
    {
System.out.println(Arrays.asList(args));
    }
}


Reference




No comments:

Post a Comment