永发信息网

这个循环里的 x = x + "the number is "+ i + "<br>";为什么是x=x+...而不可以直接写成x=...呢?

答案:1  悬赏:60  手机版
解决时间 2021-04-03 16:56
  • 提问者网友:树红树绿
  • 2021-04-02 18:13
这个循环里的 x = x + "the number is "+ i + "<br>";为什么是x=x+...而不可以直接写成x=...呢?
最佳答案
  • 五星知识达人网友:底特律间谍
  • 2021-04-02 19:13
x=x+...实现字符串的拼接
如果用x=...,每次循环都会覆盖原有x的值追问可不可以具体说一下,比如执行两次循环的结果,以及每次循环X的值是多少追答对于x=x+...:

i=0时,x="the number is 0
";
i=1时,x="the number is 0
the number is 1
";
i=2时,x="the number is 0
the number is 1
the number is 2
";

对于x=...:

i=0时,x="the number is 0
";
i=1时,x="the number is 1
";
i=2时,x="the number is 2
";
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯