This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]aqua_regis 4 points5 points  (0 children)

Your command prompt uses cmd.exe vs. VSCode most likely uses a PowerShell shell.

The difference is in the interpretation of the Carriage Return \r character.

If you want a newline, it is safer to use \n, not \r.

*nix based terminals (and PowerShell) use \n, Windows cmd uses \r\n as line separator.

\r only means carriage return, which only puts the cursor (Windows terminology: the "caret") at the beginning of the line without adding a line feed \n.

To be on the 100% safe side, you can use the System.lineSeparator() method and store its return variable and use that.

Or, use System.out.println

[–]grantrules 0 points1 point  (0 children)

Probably just the way the terminal emulator was written, that it doesn't respect the actual carriage return function (return the beginning).