您的位置:首页 > 编程语言 > Java开发

Java Puzzlers笔记--puzzle 14: Escape Rout (")双引号的问题

2007-03-04 12:14 841 查看
 public class EscapeRout{
       public static void main(String[] args){
              // /u0022 is the Unicode escape for double quote(");
             System.out.println("a/u0022.length() + /u0022b".length());
 }
}

 Soulution:

                  显示:2

                  其实是"ab"的字符长度。java认为/u0022也是双引号

TID:

                 Java provides no special treatment for Unicode escapes within string literals.The compiler translates Unitcode escapes into the characters they represents before it parses the program into tokens, such as strings literals.

                  A Unicode escape means exactly the same things as the character that it represents.

                 prefer escape sequences to Unicode escape in string and character literals.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息