today I was reading in the java Tutorials docs from Oracle about Formatting Numeric Print Output and I encountered println()
vs printf()
vs format()
after I understood the differences I read the following sentence which makes no sense for me.
A new line character appropriate to the platform running the application. You should always use %n, rather than \n.
so the main question of this is why "should" I always use %n
instead of \n
what difference does this make?
The %n is like a placeholder for whatever the newline character may be for a particular system. %n could very well be \n for a specific system or \r\n for another such as the case with windows. Using %n is the safer alternative to typing \n because as @user85421 commented, some windows applications don't recognize \n.