I saw someone initialize and array like this in java
int[] s;
s = new int[]{ and put the list here..}
versus
int[] s = { the list here}
Are these both acceptable way of doing it?
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.
Yes, both are equally valid ways of creating a java integer array. The second version is just
a shortcut syntax of the first version.
More on that here : http://download.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html