Java logoJava/
JAVA-W0379

Format strings should use `%n` instead of `\\n`JAVA-W0379

Minor severityMinor
Anti-pattern categoryAnti-pattern

This format string includes a newline character (\\n). This may cause issues on platforms like Windows that do not use Unix line separators.

In format strings, it is generally preferable to use %n, which will produce the platform-specific line separator.

Bad practice

String.format("%s\\n%d", "number", 3);
String.format("%s%n%d", "number", 3);

References