rout66,Escape Rout

public class EscapeRout {
public static void main(String...strings){
System.out.println("a\u0022.length() + \u0022b".length());
}
}
这一行会打印什么呢?
2
实质上第三行编译的结果是:
System.out.println(“a”.length() + “b”.length());
如果将这行改成:
System.out.println("a\".length() + \"b".length());
那么打印的结果是:
16
In summary, prefer escape sequences to Unicode escapes in string and character literals. Unicode escapes can be confusing because they are processed so early in the compilation sequence. Do not use Unicode escapes to represent ASCII characters. Inside of string and character literals, use escape sequences; outside of these literals, insert ASCII characters directly into the source file.
Tags:  escape iprout rout66

延伸阅读

最新评论

发表评论