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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.