Is there a difference between:
public void main(String args[]) { ... }
and
public void main(String[] args) { ... }
I don't believe so, but I am wondering.
Semantically, they are identical. However, I'd recommend using the latter syntax (String[] args) when declaring arrays. The former syntax is there mainly for compatibility with C syntax.
String[] args
Since String[], as a whole, is the type of the object in Java, it's more consistent and clear not to split it up.
String[]
A similar question addresses the [] after method argument list.
[]
1.4m articles
1.4m replys
5 comments
56.9k users