Java Puzzlers笔记--puzzle 10: Tweedledee += 问题(2)
2007-03-03 19:18
495 查看
x = x + i;
but this is not:
x += i;
Solution:
Objext x = "Buy ";
Stirng i = "Effective java!";
x = x + i;//it's legal.显示:But Effective java!
x += i; //it's illegal.因为+=操作符没有对String类型的定义。
TID:
The += operator allows its right-hand operand to be of any type if the variable on
the left-hand side is of type String, in which case the operator performs string
concatenation.
but this is not:
x += i;
Solution:
Objext x = "Buy ";
Stirng i = "Effective java!";
x = x + i;//it's legal.显示:But Effective java!
x += i; //it's illegal.因为+=操作符没有对String类型的定义。
TID:
The += operator allows its right-hand operand to be of any type if the variable on
the left-hand side is of type String, in which case the operator performs string
concatenation.
相关文章推荐
- Java Puzzlers笔记--puzzle 9: Tweedledum +=的问题
- Java Puzzlers笔记--puzzle 19: Classy Fire 注释问题
- Java Puzzlers笔记--Puzzle 2: Time for a change 关于浮点型的问题
- Java Puzzlers笔记--puzzle 13: Animal Farm 优先级以及对象引用问题
- Java Puzzlers笔记--puzzle 14: Escape Rout (")双引号的问题
- Java Puzzlers笔记--puzzle 15: Hello Whirled -Unicode字符问题
- Java Puzzlers笔记--Puzzle 3: Long Division 溢出问题
- Java Puzzlers笔记--puzzle 5: The joy of Hex 十六进制计算问题
- Java Puzzlers笔记--puzzle 21: What's my Class, take 2 路径字符问题
- Java Puzzlers笔记--puzzle 7: Swap Meat ^符号问题
- Java Puzzlers笔记--puzzle 17: Huh? 转义字符问题
- Java Puzzlers笔记--puzzle 8: Dos Equis 选择操作符问题
- selenium 学习笔记 ---新手学习记录(10) 问题总结(java)--poi--excel 操作
- Java Puzzlers笔记--puzzle 22:Dupe of URL url的使用
- Java Puzzlers笔记--puzzle 20: What's my Class? String.replaceAll()的使用
- 读Java Puzzlers笔记: 表达式问题
- Java Puzzlers笔记--puzzle 6: Multicast 类型转换
- Java Puzzlers笔记--puzzle 11: The last laugh "" 与''的区别
- Java Puzzlers笔记--puzzle 12: ABC String与char的区别
- Java Puzzlers笔记--Puzzle 1: Oddity奇偶问题