Skip to content
← Back to Community
Newline Characters
Profile icon
posiedon7776

How do I type in newline characters? Is there some kind of shortcut? Because currently I copy and pasted it from another person's repl.

Answered by PattanAhmed [earned 5 cycles]
View Answer
Voters
Profile icon
posiedon7776
Comments
hotnewtop
Profile icon
PattanAhmed

@posiedon7776 Hi,
You can use \n(backslash n) for printing the statement in the next line:-

System.out.print("Ahoy\nWorld")

You will get the next statement (World) in the different line.
That's it
Thanks!

Hope this helps

Profile icon
mwilki7

If you ever have the misfortune of running your programs on windows machines you may also have to add "\r\n" if "\n" doesn't work.

Profile icon
DynamicSquid

\n

for example:

System.out.print("Hello\nWorld")

will print:

Hello World

or

System.out.println("Hello"); System.out.println("World");

will print out:

Hello World