Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#149 array should contain the optional trailing comma

release_3.2
closed
Check (274)
5
2012-10-10
2003-03-03
Peter Dobratz
No

When you instantiate an array, it is legal to put a
comma after the last element:

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

Putting this comma in make is easier to change the
order of the elements or add new elements on the end.

--Peter

Discussion

  • Lars Kühne
    Lars Kühne
    2003-03-03

    Logged In: YES
    user_id=401384

    but only if LCURLY and RCURLY are on different lines?

    Example: I would still want to be able to write

    return new int[] { 0 };

     
  • Logged In: YES
    user_id=746148

    ArrayTrailingComma check integrated in CVS.
    Will be available in Checkstyle 3.2.