From 007aa9b66eee29634b454279b42eda79708d054d Mon Sep 17 00:00:00 2001 From: Rahul Srivastava Date: Fri, 16 Nov 2018 11:22:18 +0530 Subject: [PATCH] Changing para to rhyme --- .../string/AddingNewLineToString.java | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/core-java/src/main/java/com/baeldung/string/AddingNewLineToString.java b/core-java/src/main/java/com/baeldung/string/AddingNewLineToString.java index 0b3fd2ca92..b522f7337b 100644 --- a/core-java/src/main/java/com/baeldung/string/AddingNewLineToString.java +++ b/core-java/src/main/java/com/baeldung/string/AddingNewLineToString.java @@ -5,65 +5,65 @@ public class AddingNewLineToString { public static void main(String[] args) { String line1 = "Humpty Dumpty sat on a wall."; String line2 = "Humpty Dumpty had a great fall."; - String para = ""; + String rhyme = ""; System.out.println("***New Line in a String in Java***"); //1. Using "\n" System.out.println("1. Using \\n"); - para = line1 + "\n" + line2; - System.out.println(para); + rhyme = line1 + "\n" + line2; + System.out.println(rhyme); //2. Using "\r\n" System.out.println("2. Using \\r\\n"); - para = line1 + "\r\n" + line2; - System.out.println(para); + rhyme = line1 + "\r\n" + line2; + System.out.println(rhyme); //3. Using "\r" System.out.println("3. Using \\r"); - para = line1 + "\r" + line2; - System.out.println(para); + rhyme = line1 + "\r" + line2; + System.out.println(rhyme); //4. Using "\n\r" Note that this is not same as "\r\n" // Using "\n\r" is equivalent to adding two lines System.out.println("4. Using \\n\\r"); - para = line1 + "\n\r" + line2; - System.out.println(para); + rhyme = line1 + "\n\r" + line2; + System.out.println(rhyme); //5. Using System.lineSeparator() System.out.println("5. Using System.lineSeparator()"); - para = line1 + System.lineSeparator() + line2; - System.out.println(para); + rhyme = line1 + System.lineSeparator() + line2; + System.out.println(rhyme); //6. Using System.getProperty("line.separator") System.out.println("6. Using System.getProperty(\"line.separator\")"); - para = line1 + System.getProperty("line.separator") + line2; - System.out.println(para); + rhyme = line1 + System.getProperty("line.separator") + line2; + System.out.println(rhyme); System.out.println("***HTML to rendered in a browser***"); //1. Line break for HTML using
System.out.println("1. Line break for HTML using
"); - para = line1 + "
" + line2; - System.out.println(para); + rhyme = line1 + "
" + line2; + System.out.println(rhyme); //2. Line break for HTML using “ ” System.out.println("2. Line break for HTML using "); - para = line1 + " " + line2; - System.out.println(para); + rhyme = line1 + " " + line2; + System.out.println(rhyme); //3. Line break for HTML using “ ” System.out.println("3. Line break for HTML using "); - para = line1 + " " + line2; - System.out.println(para); + rhyme = line1 + " " + line2; + System.out.println(rhyme); //4. Line break for HTML using “ ;” System.out.println("4. Line break for HTML using "); - para = line1 + " " + line2; - System.out.println(para); + rhyme = line1 + " " + line2; + System.out.println(rhyme); //5. Line break for HTML using \n” System.out.println("5. Line break for HTML using \\n"); - para = line1 + "\n" + line2; - System.out.println(para); + rhyme = line1 + "\n" + line2; + System.out.println(rhyme); } } \ No newline at end of file