+ 2

Pls whats the meaning of this in java "/n"

"/n"

23rd Apr 2017, 4:19 PM
Peter ThankGod
Peter ThankGod - avatar
10 Answers
+ 30
"\n" is new line. (not /n) System.out.println("Peter\nThankGod"); Output : Peter ThankGod
23rd Apr 2017, 4:22 PM
Shamima Yasmin
Shamima Yasmin - avatar
23rd Apr 2017, 4:28 PM
Hatsy Rei
Hatsy Rei - avatar
+ 13
An escape sequence \n, is used to move to the next line
23rd Apr 2017, 6:47 PM
Sachin Artani
Sachin Artani - avatar
+ 10
this known in CPP as "new line" .
23rd Apr 2017, 6:57 PM
Saja Husam
Saja Husam - avatar
+ 10
cout<<endl; or cout<<" \n"; same thing it moves to a new line .
23rd Apr 2017, 6:58 PM
Saja Husam
Saja Husam - avatar
+ 8
its same as <br> of html and /n is used in js
23rd Apr 2017, 4:30 PM
Prashanth Kumar
Prashanth Kumar - avatar
+ 8
/n does nothing, it's just /n. What you mean to say is \n. This puts the console to a new line. Example: System.out.println("example\ntest"); Output: example test Where as I would have needed to write this to get the equivalent output: System.out.println("example"); System.out.println("test"); \ is an escape character in a string, which allows you to interpret a different set of characters instead of having the \. example: \t -> equivalent to tabbing text if you want to get a \ (character) then use \\. You can see a further list of escape characters here: https://docs.oracle.com/javase/tutorial/java/data/characters.html There's also plenty of other explanations on what \n is encase your still confused here: https://www.sololearn.com/Discuss/264168/why-writing-n-inside-the-cout-statement-it-prints-n https://www.sololearn.com/Discuss/158151/use-of-n
23rd Apr 2017, 4:30 PM
Rrestoring faith
Rrestoring faith - avatar
+ 2
It creates a new line.
23rd Apr 2017, 4:23 PM
Rob Howard
Rob Howard - avatar
+ 1
It is string.
23rd Apr 2017, 4:24 PM
Raj Sharma
+ 1
I understand now; thanks
23rd Apr 2017, 4:29 PM
Peter ThankGod
Peter ThankGod - avatar