The comma ,
items separator used in an array initialization list may end the list in C, this is mentioned in The C Programming Language 2nd ed by Kernighan & Ritchie .
e.g.
int c[] = { 1, 2, 3, };
This is convenient when the list is long, and one doesn't want to have to change/check the previous line when adding items
long long c[] = {
22342342344,
4324234234,
12312311111,
};
However in Java I could observe two different behaviors:
In Eclipse, the ending ,
is accepted while some versions of the maven compiler plugin complain and throw a compilation error.
However, I didn't find any mention of this singularity in the Flanagan's Java book.
What is the official rule regarding an ending comma after the initialization items?
Is it recommended not to use it?