0

What is the difference between System.lineSeparator() and \n? When to use?

13th Dec 2016, 3:56 AM
Pukhramabam Prameshwormani Singh
2 Answers
0
System.lineSeparator takes into consideration the line separator of the current os. In windows is \n but on IOS and Linux I think it's different, so if you use \n and try to run the program in Linux it may have problems, if you use System.lineSeparator () you don't have to worry about that.
13th Dec 2016, 9:22 AM
Jax
Jax - avatar
0
In windows, new line is represented by '\r\n' while Linux uses '\n' as newline. So System.lineSeparator() takes line separator of the current os.
8th Nov 2017, 3:58 PM
ankit garg
ankit garg - avatar