Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

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

user-image
Question ajoutée par Asutosh jena Asutosh jena
Date de publication: 2013/12/09
Mukesh Kumar
par 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...

Utilisateur supprimé
par Utilisateur supprimé

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