Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the backslash character (\\)?

Tags:

What is the string literal \\ backslash? What does it do? I have thought about it but I do not understand it. I also read it on wikipedia. When I try to print the following:

System.out.println("Mango \\ Nightangle"); 

the output is: Mango \ Nightangle

What is the significance of this string literal?

like image 848
Y.E.P Avatar asked Aug 23 '12 12:08

Y.E.P


People also ask

What is the slash character called?

It is called a solidus in Unicode, is also known as an oblique stroke, and has several other historical or technical names including oblique and virgule.

Where is the back slash?

Answer: The backslash key is located near the "Enter" or "Return" key on most keyboards. It is most often found directly to the left of the Enter key, but can also be placed below or above the enter key.


1 Answers

\ is used as for escape sequence in many programming languages, including Java.

If you want to

  • go to next line then use \n or \r,
  • for tab use \t
  • likewise to print a \ or " which are special in string literal you have to escape it with another \ which gives us \\ and \"
like image 156
Chandra Sekhar Avatar answered Sep 23 '22 02:09

Chandra Sekhar