Is there any difference between %n and \n ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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?

12th Feb 2019, 2:48 PM
Lev Tolstoy SPB
Lev Tolstoy SPB - avatar
2 Answers
+ 5
Now it's clear. The %n is platform-independent newline character. Original source: https://docs.oracle.com/javase/tutorial/java/data/numberformat.html
12th Feb 2019, 3:51 PM
Lev Tolstoy SPB
Lev Tolstoy SPB - avatar