-1
int [][] a = {{1,2,},{3,4}};
int [][] a = {{1,2},{3,4}};

i have two Multidimensional arrays in java. I want to know what's the exact difference in both of them.just see there is a comma after 2 in first one.

0

2 Answers 2

2

JLS 10.6. Array Initializers: A trailing comma may appear after the last expression in an array initializer and is ignored.

Sign up to request clarification or add additional context in comments.

Comments

1

There is no difference. The extra comma might be useful if you are formatting your elements one per line, so that every element appears the same.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.