1. octal escape sequence: \ + 1 to 3 digits and 5 digits; range: '\ 000 '~ '\ 100'
\ 0: NULL characters
2. Unicode escape characters: \ U + four hexadecimal numbers; 0 ~ 65535
\ U0000: NULL Character
3. Special characters: Three
\ ": Double quotation marks
\ ': Single quotes
\: Backslash
4. control characters: 5
\ 'Single quotes
\ Backslash character
\ R press ENTER
\ N line feed
\ F go to paper form
\ T horizontal hop
\ B Return
Point escape:. ==> u002e
Escape of dollar signs: $ ==> u0024
Escape of the multiplication Symbol: ^ ==> u005e
Escape from the left braces: {==> u007b
Escape from left square brackets: [==> u005b
Escape of left parentheses :( ==> u0028
Escape of vertical bars: |=> u007c
Escape of right parentheses: ==> u0029
Asterisk escape: * ==> u002a
Escape of the plus sign: + ==> u002b
Escape question mark :? ==> U003f
Escape the backslash: ==> u005c
Line breaks have different forms in different systems:
\ N: text file line break in Mac OS
\ R: UNIX text file line break
\ R \ n: text file line break in Windows
The following program uses two Unicode escape characters, which use their hexadecimal code to represent Unicode characters. So what will this program print?
Java code
Public class escaperout {
Public static void main (string [] ARGs ){
// \ U0022 is the Unicode Escape Character of double quotation marks
System. Out. println ("A \ u0022.length ()
+ \ U0022b ". Length ());
}
}
Public class escaperout {
Public static void main (string [] ARGs ){
// \ U0022 is the Unicode Escape Character of double quotation marks
System. Out. println ("A \ u0022.length ()
+ \ U0022b ". Length ());
}
}
The general analysis of this program will think that it should print out 26 characters, because there are a total of 26 characters between strings identified by two double quotes "A \ u0022.length () + \ u0022b.
A little deeper analysis will assume that the program should print 16, because each of the two Unicode escape characters must be represented by six characters in the source file, but they only represent one character in the string. Therefore, this string should be 10 characters shorter than its appearance. If you run this program, you will find that this is far from the case. It neither prints 26 nor 16, but 2.
Java does not provide any special processing for Unicode escape characters in string literal constants. The compiler first converts Unicode escape characters into the characters they represent before parsing the program into symbols, the first Unicode Escape Character in the program is used as the ending quotation mark of a single character string literal constant (", the second Unicode escape character is used as the start quotation mark of another single character string literal constant ("B. The program prints the expression "a". Length () + "B". Length (), that is, 2