0
Difference between \r and \n escape characters?
public class Program { public static void main(String[] args) { System.out.println("Hello\rWorld"); //Output: Hello // World System.out.println("Hello\nWorld"); //Output: Hello // World } } There's the same output. Could someone explain me what's the difference between \r and \n escape characters? Maybe with a short example.
2 Antworten
+ 4
>>> print('Hello\rWorld')
World
>>> print('Hello\nWorld')
Hello
World
https://stackoverflow.com/questions/7372918/whats-the-use-of-r-escape-sequence
0
\r is a carriage return, it has the same function as a new-line, but was used on mac OS until mac OS X, \n is a new line character used for linux systems (and mac OS X), and "\r\n" is for windows systems
java supports all of these because java can be used on any OS