java转义字符(Java escape character)
java转义字符(Java escape character)
Escape the escape character in 17:40JAVA 2009-08-12 characters in JAVA:
The 1. octal escape sequence: \ + 1 to 3 5 numbers;'\000'~'\377'
\0: empty character
2.Unicode escape character: \u + four sixteen hexadecimal numbers; 0~65535
\u0000: empty character
3. special characters: 3
"Double quotes:
'single quotes:
A backslash \ \:
4. control characters: 5
'singlequotedcharacter
The backslash character \ \
Enter \r
\n wrap
\f paper page
\t horizontal jump
\b backspace
The escape: ==> u002E.
The dollar sign: $==> u0024
The escape symbol: u005E ^ ==> involution
Escape left brace: {==> u007B
Escape the left bracket: ==> [u005B
The left parenthesis: ==> (u0028
A: | ==> escape u007C
Escape right parenthesis: ==>) u0029
An asterisk * ==> escape: u002A
Plus: u002B + ==> escape
Mark: u003F ==> escape?
Escape backslash: ==> u005C
======================================================================
The following program uses two Unicode escape character, they are used to represent the Unicode character hexadecimal code sixteen. So, what will the program print?
Java code
Public class EscapeRout{
Public static void main (String[] args) {
/ / \u0022 is a Unicode escape double quotes
System.out.println ("a\u0022.length ()
+\u0022b (.Length));
}
}
Public class EscapeRout{
Public static void main (String[] args) {
/ / \u0022 is a Unicode escape double quotes
System.out.println ("a\u0022.length ()
+\u0022b (.Length));
}
}
On a very superficial analysis of the program will think it should print out the 26, because in the two double quotes "(a\u0022.length) a total of 26 characters between the string +\u0022b" logo.
A little further analysis point that the program should print 16, because the two Unicode escape character in each source file need to use 6 characters to say, but they only said a character in a string. Therefore, this should be the shorter string of 10 characters than it looks. If you run this program, you will find things are not so. This p