ripper234 ripper234 - 1 year ago 62
Java Question

What's up with Java's "%n" in printf?

I'm reading Effective Java and it uses

for the newline character everywhere. I have used
rather successfully for newline in Java programs.

Which is the 'correct' one? What's wrong with
? Why did Java change this C convention?

Answer Source

From a quick google:

There is also one specifier that doesn't correspond to an argument. It is "%n" which outputs a line break. A "\n" can also be used in some cases, but since "%n" always outputs the correct platform-specific line separator, it is portable across platforms whereas"\n" is not.

Please refer

Original source

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download