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.
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.Since
String[]
, as a whole, is the type of the object in Java, it's more consistent and clear not to split it up.A similar question addresses the
[]
after method argument list.Although both are used to create array of String type but second one is more popular, because with that, you can create multiple String arrays simultaneously... E.g
String[] a,b;
Here you have created two String Arrays a and b simultaneously.However
String a[],b;
will create String array "a" and String variable(not array) b.Hope this clarifies.
No
They are just two style of writting