Possible Duplicate:
Arrays with trailing commas inside an array initializer in Java
Why the following statement is correct in java:
int[][] a = { {1,2,}, {3,4}};
Whether should be compilation error because of unnecessary comma ?
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.
Trailing commain a array initialization like that areignored by compiler. Those are generally added so that later on adding something to the array, just requires adding the element without worrying about comma.It is wierd, but is allowed.
This is also listed in
JLS - Section#10.6 (Array Initializers): –