Empty trailing comments? Do they know anything?

I am looking at some code in the butterknife Android 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 it a little weird to have what looks like empty comments after each line, but no comments. This reminded me a bit of line continuation in C macros, but I had never encountered this before in java.

Does this really fulfill something / is there some kind of agreement here where it is used?

+6
source share
1 answer

The only goal I know of is to prevent the automatic indentation from moving the next line. For example, on my system without comment // end of line auto-indent gives

 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); 
+6
source

Source: https://habr.com/ru/post/976308/


All Articles