+ 4

[DUPLICATE] What is the difference?

What is the difference between public static void main(String[] args) and public static void main(String args[]) Please someone clear this.

12th Jan 2018, 12:59 PM
RAJESH SINHA
RAJESH SINHA - avatar
6 Answers
+ 3
It usually doesn't matter where the '[]' are placed in this situation, just know that "main method" in Java is the entry point for the Java Virtual Machine as long as the signature is correct, which is "public static void main(String ... args)", where the "public and static" can change their order, and the argument name (usually "arg") can be any variable name accepted by Java, and the argument data type can be an array like "String ..." (in this case the 3 dots go right after the String) or "String []" (again the [] can go before or after the argument name). Please consider that the "main" method can be overwritten and/or overloaded, but the JVM won't see that version of the main method as the application's entry point.
12th Jan 2018, 3:16 PM
Roberto Guisarre
Roberto Guisarre - avatar
+ 16
U can also write "public static void main (String ... hello){}"
12th Jan 2018, 3:00 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 3
There are many possibilities for writing the main method. There isn't really a significant difference.
12th Jan 2018, 1:07 PM
Lucien
Lucien - avatar
+ 1
Thanks Lucien
12th Jan 2018, 1:13 PM
RAJESH SINHA
RAJESH SINHA - avatar
+ 1
main(String[] args) main(String []args) main(String args[]) main(String ... args) we can write those form and all are the corrects.
12th Jan 2018, 8:05 PM
Mohammadaassif
Mohammadaassif - avatar
0
Thanks a lot Roberto & Gaurav
12th Jan 2018, 3:22 PM
RAJESH SINHA
RAJESH SINHA - avatar