Thursday, July 23, 2015

public static void main (String[] args)

public static void main (String[] args)

What does this syntax mean in your JAVA program ?

public - This is the access modifier. Being declared as public means it can be called from anywhere. This makes sense because the JVM is going to call this method.

static - If we don't declare it as static then JVM will have to make an instance (object) to call this method. Static makes it a class level method which does not require any object to be called.

void - We dont have to return anything to the JVM, hence void declaration makes sense.

main - Predefined method name which the JVM tries to call automatically. Java is case-sensitive, Main is different from main.

String[] args - Argument list that can be passed from the command prompt to the JAVA program.

No comments:

Post a Comment

Home