Java array initialization list ending with a comma

前端 未结 3 1090
逝去的感伤
逝去的感伤 2020-12-19 07:16

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

相关标签:
3条回答
  • 2020-12-19 07:38

    Sun javac has a bug wrt parsing trailing commas in annotations.

    https://bugs.eclipse.org/bugs/show_bug.cgi?id=284088

    0 讨论(0)
  • 2020-12-19 07:49

    Section 10.6 of the spec explicitly says that a trailing comma is allowed (and ignored):

    A trailing comma may appear after the last expression in an array initializer and is ignored.

    Link

    0 讨论(0)
  • 2020-12-19 07:56

    From the Java Language Specification, section 10.6:

    A trailing comma may appear after the last expression in an array initializer and is ignored.

    0 讨论(0)
提交回复
热议问题