+ 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.
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.
+ 16
U can also write "public static void main (String ... hello){}"
+ 3
There are many possibilities for writing the main method. There isn't really a significant difference.
+ 1
Thanks Lucien
+ 1
main(String[] args)
main(String []args)
main(String args[])
main(String ... args)
we can write those form and all are the corrects.
0
Thanks a lot Roberto & Gaurav