Saturday, July 20, 2013

Java - New Line Separator


A string can be constructed to have new line as 
String string = "Hello" + "\n" + "World"; 

Output 

Hello
World

Instead of using "\n", a better way to get the new line is from the System class.
A new line separator is stored in the System class in a Properties object. 
The new line separator can be retrieved by the following line 

System.getProperty("line.separator");


No comments:

Post a Comment