character, from the literal understanding, is some char type of East, but put in the program, the extension of a variety of interpretation methods
1. Escape character
In the program, when is the escape character interpreted by the compiler? Its interpretation time can be understood as before compiling, the compiler first to the escape character substitution.
For example, the following program segment:
(a)//\u0022 is "
System.out.println ("A\u0022.length () +\u0022b". length);
Printing 2
(b) One line of comments is:/*from f:/a/b/c/unit*/
Is this legal? Note that the compiler finds that \u will assume that a Unicode code is followed, and the comment does not follow a four-digit number, and the compiler rejects the compilation
Original aim, read the program, notice the escaped Unicode code, and then convert it to recompile.
Tip: Do not use Unicode escape characters casually, unless forced
2. Special characters of regular expressions
This is an understanding of regular expressions.
String.replaceall supports regular expressions, so it is important to use this function.
Such as: There is already a class of com.javapluzzlers.Me
Me.class.getName (). ReplaceAll (".", "/") + ". Class";
Will it be com/javapluzzlers/me.class after replacement?
Not found after running. Because "." Matches any character in the regular, and replaces it with a string of/////////////.class,
3. URL
Since Java supports tags, will this segment be compiled if there is a http://blog.csdn.net-like statement in the program segment? The answer is yes.
Because http: is understood as a label, and//blog.csdn.net is interpreted as a comment, there is clearly no grammatical error.
4, the parameter number character
Examine the next stringbuffer.
StringBuffer SF = new StringBuffer (' M ');
Sf.add ("a");
System.out.println (SF);
Print What? Would it be MA?
The view API finds that StringBuffer does not have a constructor with a parameter of char, but there is a constructor with a parameter of int, so the declaration statement actually declares a buffer with a size of ' M ' (77).
The Mystery of character