+ 4

[DUPLICATE] What is the Difference between main(String[] args) and main(String args[]) ?

I have seen that some programers write in both ways, but I want to know the difference and why you can write it in both ways without an error appear.

30th Jul 2016, 3:54 AM
edu
edu - avatar
5 Answers
+ 19
No difference at all, just preference. You can even write it (String []args) if you wanted. This is because of how the language was designed. It is usually best practice to do String[] args though. This follows standard array declaration like int[] x. Doing int x[] would only be done if you're creating several int variables but only 1 is an array. Like int x, y[], z; Creates three variables of int, x y and z, but only y is an array.
30th Jul 2016, 4:01 AM
James
James - avatar
+ 1
there is no difference between these two...we can write in any of these two ways
3rd Feb 2017, 4:41 PM
Ashu Bagul
Ashu Bagul - avatar
0
i guess it s the same thing
4th Aug 2016, 7:55 PM
huguette sandrine
huguette sandrine - avatar
0
both are same it's array declaration of type string with the name args you are allowed to change the name args as : argu, arr, array, etc whatever you want because it's just a name of an array of type string
5th Aug 2016, 6:33 AM
sachin tomar
sachin tomar - avatar
0
learn about array to make you understand it clearly
23rd Dec 2016, 10:40 AM
Mangaranap Parulian Sianturi
Mangaranap Parulian Sianturi - avatar