Java and Java escape characters
Escape Character refers to the combination of some common characters to replace some special characters. Because its combination changes the meaning of the original character representation, it is called "escape ".
Common escape characters:
\ N press enter (\ u000a)
\ T horizontal tab (\ u0009)
\ B space (\ u0008)
\ R line feed (\ u000d)
\ F form feed (\ u000c)
\ 'Single quotes (\ u0027)
\ "Double quotation marks (\ u0022)
\ Backslash (\ u005c
Example:
String greeting = "Good Morning !! \ N"
What are escape characters in java and why should they be escaped?
Take the "\" symbol as an example. There are many operations in JAVA, such as file operations. The path must be used, such as com \ mypackage \ xxx. xml, this path is generally represented in the form of a string, but the problem arises. JAVA does not know whether your \ number is the meaning of the next layer in the path or the meaning of the string.
Therefore, the correct method should be com \ mypackage \ xxx. xml.
For example, if we press enter directly in the middle of the string, java will not wrap the string, because he doesn't know if you want to write the code in two lines or split the string into two lines for display, you need to add \ n escape characters in the middle of the string to wrap the string.
In short, the meaning of escape characters is to avoid ambiguity, which is not allowed by all programming languages.
In java, what is the Escape Character \'?
I cannot remember specific characters with special meanings
Output "\" requires: System. out. println ("\\");
Output ": System. out. println ("\"");
In some methods, when passing parameters is special characters.
Output can be directly output, but some parameters must be \. Otherwise, errors may occur.