%n
instead of \\n
JAVA-W0379This 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.
String.format("%s\\n%d", "number", 3);
String.format("%s%n%d", "number", 3);