What is the deference between these codes. which one is bestpractice. Why there is three syntax for same. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the deference between these codes. which one is bestpractice. Why there is three syntax for same.

public static void main(String[] args) public static void main(String []args) public static void main(String args[])

3rd Jun 2017, 2:42 PM
ASHMIL HUSSAIN
ASHMIL HUSSAIN - avatar
1 Answer
+ 2
The only difference is syntax. I would say String[] args is the best practice. This is because, if you ever have multiple variables it is far easier to see what each variable is. Take this for example: int[] a, b , c; int x; Or, int a[], b[] c[], x; Now you could put the x on a different line, but the point is that you have to look at the variable to see if its an array or not. While in the first case you only needed to look at the left side and you can tell right away they're all arrays. IMO it's just easier to see the String[] when dealing with multiple variables.
3rd Jun 2017, 3:25 PM
Rrestoring faith
Rrestoring faith - avatar