+ 1
How can I leave one line empty after the code?
Hello everybody. Tell me please, how can I leave one line empty after the code? System.out.prinln("Hello"); System.out.prinln("world!"); __________________________ Hello world! But I need: Hello <----one line empty world! How can i do this?
3 Respuestas
+ 6
Here's 2 different ways:
System.out.println();
// This will move the console to the next line, without showing any text
Place this empty println statement between the hello and world println statements.
Or, you can use \n
\ is an escape character, using \n in a String will basically do the same thing as an empty println.
(Move to the next line)
Example/
System.out.println("Hello\n\nWorld!");
Output:
Hello
World!
Note*
If I used a single \n the output would be like this:
Hello
World!
Without the extra space.
0
Thank you!
0
System.out.println("Hello"+
"\n\nWorld!");
This also works if you want to make your code look better!