課程
/后端開發(fā)
/Java
/Java入門第三季
既然說String類具有不可變性,而StringBuilder和StringBuffer具有可變性,怎么個(gè)可變法,能否具體舉例說明?
2016-07-23
源自:Java入門第三季 2-5
正在回答
? ?String temp = "哇哈哈"; ? ?System.out.println(temp+"1234"); ? ?// 兩個(gè)空間,分別是temp和temp+"1234" ? ?StringBuilder sb = new StringBuilder("哇哈哈"); ? ?System.out.println(sb.append("1234")); ?// 一個(gè)空間
雪中_悍刀行 提問者
有點(diǎn)理解了,一個(gè)相當(dāng)于在原來的位置旁邊接著寫,另一個(gè)相當(dāng)于把原來的擦掉重寫.
delete(int?start, int?end)
Removes the characters in a substring of this sequence.
replace(int?start, int?end,?String?str)
Replaces the characters in a substring of this sequence with characters in the specified?String.
舉報(bào)
Java中你必須懂得常用技能,不容錯(cuò)過的精彩,快來加入吧
3 回答不是說StringBuilder類型的字符串可以更改嘛?
4 回答Stringbuilder創(chuàng)建的字符串不是就可以修改嗎?
1 回答對(duì)StringBuilder字符串的插入
1 回答StringBuilder是在原有的地址里去改變原來的字符串嗎?
2 回答字符串轉(zhuǎn)換為基本類型
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2016-07-23
? ?String temp = "哇哈哈";
? ?System.out.println(temp+"1234"); ? ?// 兩個(gè)空間,分別是temp和temp+"1234"
? ?StringBuilder sb = new StringBuilder("哇哈哈");
? ?System.out.println(sb.append("1234")); ?// 一個(gè)空間
2018-06-12
有點(diǎn)理解了,一個(gè)相當(dāng)于在原來的位置旁邊接著寫,另一個(gè)相當(dāng)于把原來的擦掉重寫.
2016-07-23
delete(int?start, int?end)
Removes the characters in a substring of this sequence.
replace(int?start, int?end,?String?str)
Replaces the characters in a substring of this sequence with characters in the specified?String.