為什么用append()方法分別追加字符串("imooc")和整數(shù)(520),hello與imooc之間有空格,imooc與520之間沒有空格?
代碼:
StringBuilder str =new StringBuilder ("hello");
str.append("imooc");
str.append("520");
System .out .println(str);
運行結(jié)果:
hello ?imooc520?
代碼:
StringBuilder str =new StringBuilder ("hello");
str.append("imooc");
str.append("520");
System .out .println(str);
運行結(jié)果:
hello ?imooc520?
2018-05-31
舉報
2018-05-31
親 你的代碼運行結(jié)果是“helloimooc520”,見圖1;
示例代碼和你的代碼不一樣,imooc前是有一個空格滴!見圖2
仔細(xì)一點就好
啦:-D
2018-05-31
你注意看他給出的那張圖片,imooc前面有一個空格 ? ?“ imooc”
2018-05-31
拷貝你的代碼,在eclipse運行運行 輸出helloimooc520 中間沒有空格