String.substr()怎么用啊
2 回答

慕尼黑的夜晚無(wú)繁華
TA貢獻(xiàn)1864條經(jīng)驗(yàn) 獲得超6個(gè)贊
public String substring(int beginIndex,
int endIndex)
返回一個(gè)新字符串,它是此字符串的一個(gè)子字符串。該子字符串從指定的 beginIndex 處開始,直到索引 endIndex - 1 處的字符。因此,該子字符串的長(zhǎng)度為 endIndex-beginIndex。
示例:
"hamburger".substring(4, 8) returns "urge"
"smiles".substring(1, 5) returns "mile"
參數(shù):
beginIndex - 起始索引(包括)。
endIndex - 結(jié)束索引(不包括)。
返回:
指定的子字符串。
拋出:
IndexOutOfBoundsException - 如果 beginIndex 為負(fù),或 endIndex 大于此 String 對(duì)象的長(zhǎng)度,或 beginIndex 大于 endIndex。
- 2 回答
- 0 關(guān)注
- 864 瀏覽
添加回答
舉報(bào)
0/150
提交
取消