Ancient history
The carriage return is a relic of the times of old where e.g. dot matrix printers required one command to advance to a new line and a separate command to return the printer head to the beginning of the line-- these two commands are not necessarily always done at the same time, seeing as you might want to e.g. make a vertical line of some kind on the paper. This behavior maps quite well to the way console output was (and still sometimes is) designated in lines and columns: For example, Emacs is often configured to display the cursor position as rownum,colnum (see related answer on superuser).
Current behavior
Unfortunately, I couldn't find any formal definition of how Java's PrintStream.println(...)
handles these characters (if at all); Therefore, I decided to debug your code to see how at least the Oracle implementation on my system handles these characters. It seems that the "magic" is done (or rather not done) in BufferedWriter.write(String, int off, int len)
: It seems that every character in the string is simply copied to the OS output stream buffer in a very low-level fashion, without any sort of processing of the lines themselves. Therefore, the actual "appearance" of these characters is dependent on the definition thereof by the console you're displaying the output on.
TL;DR: Java is simply sending the character \r
to the output stream and it is being treated by your console as a "proper" newline; It's not Java's fault but rather your console's, and I don't know what console you're using.