Checkstyle and Eclipse; Java line continuation

(I know this is some kind of lazy question, but it is strangely hard to find ... especially since checkstyle does so much, and Google search results are dotted with verification reports).

Can someone tell me which audit reports β€œ+ should be on a new line” when splitting long lines into several lines in Java?

As an aside, this SO question in circular mode asked if there is a way to get Eclipse to put the β€œ+” character on a new line when it splits the line for you. Is there an easy way?

+4
source share
1 answer

The operator check is probably responsible for the message "+ should be on a new line." <sh> It is located in the "Spaces" section.

if there is any way to get Eclipse to put the "+" character on a new line when it splits the line for you. Is there an easy way?

The only way I know is to format the code just released:
when you press " return " in the middle of the String , " + " is displayed at the end of the first line.
But you format the code, it returns " + " at the beginning of the second.

Since you can only format the section you are in (for example, the current method you are editing), this tip does not mean that you will format the entire class anytime you want to put the + in the right place, Only the current code block .
(this is the "Format Element" command, and by default it does not have a key shortcut, so you can assign it)

+9
source

All Articles