+ 1

what is \r ??? in java.

what is \r ???

24th Dec 2016, 9:18 AM
manish rawat
manish rawat - avatar
4 ответов
+ 4
This is not only in java. '\r' is the representation of the special character CR (carriage return), it moves the cursor to the beginning of the line. '\n'(line feed) moves the cursor to the next line . On windows both are combined as \r\n to indicate an end of line (ie, move the cursor to the beginning of the next line).
24th Dec 2016, 9:33 AM
ifl
ifl - avatar
+ 3
\n is enough on linux to indicate end of line. But both are needed on windows. If you open a linux text file in notepad you will see all text on a single line. And a Windows text file in a linux editor may show a ^M at the end of each line. Most editors have a conversion option.
24th Dec 2016, 9:38 AM
ifl
ifl - avatar
0
got it
24th Dec 2016, 10:13 AM
manish rawat
manish rawat - avatar
- 1
but cant \n alone do this??
24th Dec 2016, 9:34 AM
manish rawat
manish rawat - avatar