Inspectopedia
 
2024.3

Text block can be used

Warning
New
Last modified: 03 December 2024

Reports String concatenations that can be simplified by replacing them with text blocks.

Requirements:

  • \n occurs two or more times.

  • Text blocks are not concatenated.

Use the Report single string literals option to highlight single literals containing line breaks. The quick-fix will still be available even when this option is disabled.

Example:

After the quick-fix is applied:

This inspection depends on the Java feature 'Text block literals', which is available since Java 15.

New in 2019.3