What is the backslash character (\\)?

java, string, string-literals

Solution

`\` 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 `\"`

Problem

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?

Original source