I accidentally left an extra comma at the end of one of my annotation lists, but it compiled fine on my machine. For example:
@NamedQueries({
@NamedQuery(name="name1",query="FROM Foo"),
@NamedQuery(name="name2",query="FROM Bar"),
})
Notice the extra comma after the second @NamedQuery. It seems to compile fine on my machine, but someone else had problems compiling the code on their machine, so I removed it. But I am now curious as to whether it's supposed to be allowed, and if so, what version of java allows it.
I have not been able to find any reference to this anywhere online.
Trailing commas (sometimes called "final commas") can be useful when adding new elements, parameters, or properties to JavaScript code. If you want to add a new property, you can add a new line without modifying the previously last line if that line already uses a trailing comma.
class file and a source code file, the annotation file must redundantly specify the annotation's bytecode offset and source code index. This can be done in a single . jaif file or two separate . jaif files.
Python Language Dictionary The trailing comma Like lists and tuples, you can include a trailing comma in your dictionary. PEP 8 dictates that you should leave a space between the trailing comma and the closing brace.
In Python, lists are ordered collections of items that allow for easy use of a set of data. List values are placed in between square brackets [ ] , separated by commas. It is good practice to put a space between the comma and the next value.
I think in this case you're dealing with Array Initializers that allow the extra comma.
Example:
int[] foo = new int[] { 1, 2, 3, };
This has been part of the JLS from the beginning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With