How to get a new line character or \n using Java?

Java has standard way to get line separator regarding platform which executes Java code. It is called System.lineSeparator() .

    public static void main(String[] args) {

        System.out.print("Line 1");

        // Windows \r\n, Linux \n

        System.out.print("Line 2");


Leave a Reply

Your email address will not be published. Required fields are marked *