主题:[讨论]关于setText()的问题!
笑看每一天
[专家分:0] 发布于 2007-11-16 22:06:00
setText()中不是要用String类型的吗?为什么也可以这样写:setText("nihao"+x) ?? x是int类型。
回复列表 (共2个回复)
沙发
justforfun626 [专家分:18460] 发布于 2007-11-17 04:42:00
You need to understand what is String concatenation.
"nihao"+x is String type
You can try:
String s = "nihao" + 5; // compiled
System.out.println(s); // nihao5 printed out
板凳
happyboy2007 [专家分:3900] 发布于 2007-11-17 11:02:00
这里的 + 是连接运算符,表示将String与int(或其它基本数据类型)连接为一个字符串。
我来回复