I'm looking at some of the code in the Android butterknife library and found this snippet here:
private static final List<Class<? extends Annotation>> LISTENERS = Arrays.asList(//
OnCheckedChanged.class, //
OnClick.class, //
OnEditorAction.class, //
OnFocusChange.class, //
OnItemClick.class, //
OnItemLongClick.class, //
OnItemSelected.class, //
OnLongClick.class, //
OnPageChange.class, //
OnTextChanged.class, //
OnTouch.class //
);
I found this a bit peculiar to have what looks like just empty comments after each line, but no comment text. It reminded me a little of line continuation in C macros, but I have never come across this before in java.
Does this actually accomplish anything / is there some convention here where this is used?
Trailing comments describe the action or use of a single line of code. They are usually start (and end) on the same line as the code they are commenting.
2.3. Trailing comments are used to provide an explanation for a single line of code. Begin trailing comments with a double slash ( // ) and place them to the right of the line of code they reference.
The only purpose I'm aware of is to prevent auto-indent from moving the next line up. For example, on my system without the //
end of line comments, an auto-indent yields
private static final List<Class<? extends Annotation>> LISTENERS = Arrays
.asList(OnCheckedChanged.class, OnClick.class,
OnEditorAction.class, OnFocusChange.class,
OnItemClick.class, OnItemLongClick.class,
OnItemSelected.class, OnLongClick.class,
OnPageChange.class, OnTextChanged.class, OnTouch.class);
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