Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Why we write public static void main(String[] args)?

user-image
Question added by Asutosh jena Asutosh jena
Date Posted: 2013/12/09
Mukesh Kumar
by Mukesh Kumar , Software Engineer , Team Computers Pvt. ltd

Public:      is an acces modifier used to represent visibility which means visible to all.

Static :      is a keyword  if we declaare any method as static it is known as static method. the main method is executed by JVM so it does not requre to create object to invike the main method. so it saves memory, 

void :         is a return type of method , it means it does not return any value.

main:        represent start up of the program (execution will start allways  from main () )

String args[ ]:      is used for command line argument, it store the value pass by user at the run time, it work like array...

Deleted user
by Deleted user

In the case of compiling the java code Under old (legacy ) jdk's (like1.0 to1.6) no need of writing(mentioning) main method in the java program but JDK1.7 On wards we have to encapsulate our java code in main method then only jvm considered to compile. the main method is the start point of the java code.. in old jdk's it(main) was implicitly declared but not in newer  versions........... i hope u get the point ..... :)

More Questions Like This