Java

Java

Made by DeepSource

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

Anti-pattern
Minor
Autofix

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);

Recommended

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

References