print using \n in java code example
Example 1: how to print \n in a string in java
System.out.println("\\n hello world");
// output:
// "\n hello world"
Example 2: java how to print a newline
System.out.println("<Your line here.>");
System.out.println("\\n hello world");
// output:
// "\n hello world"
System.out.println("<Your line here.>");