java println printing \n code example Example: how to print \n in a string in java System.out.println("\\n hello world"); // output: // "\n hello world"