Print in new line, java

Print in new line, java

    String newLine = System.getProperty("line.separator");//This will retrieve line separator dependent on OS.

    System.out.println("line 1" + newLine + "line2");Print in new line, java

Print in new line, java

Your best shot would be with




It is supposed to print a newline character, depending on the current platform, so it’s perfect for the console.

If you are printing to a file, then it depends.

Leave a Reply

Your email address will not be published.