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.
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.
相关文章推荐
- Java Puzzlers笔记--puzzle 15: Hello Whirled -Unicode字符问题
- Java Puzzlers笔记--Puzzle 3: Long Division 溢出问题
- Java Puzzlers笔记--puzzle 5: The joy of Hex 十六进制计算问题
- Java Puzzlers笔记--puzzle 17: Huh? 转义字符问题
- Java Puzzlers笔记--puzzle 21: What's my Class, take 2 路径字符问题
- Java Puzzlers笔记--puzzle 7: Swap Meat ^符号问题
- Java Puzzlers笔记--puzzle 8: Dos Equis 选择操作符问题
- Java Puzzlers笔记--puzzle 11: The last laugh "" 与''的区别
- Java Puzzlers笔记--puzzle 19: Classy Fire 注释问题
- Java Puzzlers笔记--Puzzle 2: Time for a change 关于浮点型的问题
- Java Puzzlers笔记--puzzle 9: Tweedledum +=的问题
- Java Puzzlers笔记--puzzle 10: Tweedledee += 问题(2)
- Java Puzzlers笔记--puzzle 13: Animal Farm 优先级以及对象引用问题
- Java Puzzlers笔记--puzzle 20: What's my Class? String.replaceAll()的使用
- 读Java Puzzlers笔记: 表达式问题
- 数据结构与算法分析笔记与总结(java实现)--链表14:删除链表中所有指定值结点问题
- Java Puzzlers笔记--puzzle 22:Dupe of URL url的使用
- Java出现错误“Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )”的问题分析
- Java Puzzlers笔记--puzzle 6: Multicast 类型转换
- Java Puzzlers笔记--Puzzle 1: Oddity奇偶问题