I have following code :
    System.out.println(" | 1  2  3  4  5  6  7  8  9");     System.out.println("----------------------------");     System.out.println("");   I use println to create a new line. Is it possible to do the same using \n or \r? I tried to add \n to the second println statment and continue printing with the print method but \n does not create a new line.
any ideas?
Each format specifier says to output the next item in the argument list at that place in the format. The printf statement does not automatically append a newline to its output. It outputs only what the format string specifies.
\n is an escape character for strings that is replaced with the new line object. Writing \n in a string that prints out will print out a new line instead of the \n. Java Escape Characters.
\t Insert a tab in the text at this point. \b Insert a backspace in the text at this point. \n Insert a newline in the text at this point.
    String newLine = System.getProperty("line.separator");//This will retrieve line separator dependent on OS.      System.out.println("line 1" + newLine + "line2"); 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With