Newlines
Always use the language-specific alternative to a platform-specific newline.
Using std::endl or \n. std::cout will correctly format \n to the correct platform newline character. It is recommended to still use std::endl. HOWEVER, std::endl will flush the ostream, so if you want to avoid that, use a plain \n (not \r\n)
Use System.lineSeperator()
BAD:
System.out.println("Hello!\n");GOOD:
System.out.println("Hello!" + System.lineSeparator());Last updated
Was this helpful?