Is there any difference between %n and \n ? | Sololearn: Learn to code for FREE!

+9

Is there any difference between %n and \n ?

As I remember official documentation suggest us to use %n instead of \n. Can anyone explain why?

2/12/2019 2:48:59 PM

Lev Tolstoy SPB

2 Answers

New Answer

+2

https://stackoverflow.com/questions/1883345/whats-up-with-javas-n-in-printf

+5

Now it's clear. The %n is platform-independent newline character. Original source: https://docs.oracle.com/javase/tutorial/java/data/numberformat.html