第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

請(qǐng)教下,關(guān)于在java中replace方法如何使用?

請(qǐng)教下,關(guān)于在java中replace方法如何使用?

陪伴而非守候 2021-06-29 11:07:36
希望有具體的例子
查看完整描述

2 回答

?
人到中年有點(diǎn)甜

TA貢獻(xiàn)1895條經(jīng)驗(yàn) 獲得超7個(gè)贊

public String replace(char oldChar,
char newChar)返回一個(gè)新的字符串,它是通過用 newChar 替換此字符串中出現(xiàn)的所有 oldChar 得到的。
如果 oldChar 在此 String 對(duì)象表示的字符序列中沒有出現(xiàn),則返回對(duì)此 String 對(duì)象的引用。否則,創(chuàng)建一個(gè)新的 String 對(duì)象,它所表示的字符序列除了所有的 oldChar 都被替換為 newChar 之外,與此 String 對(duì)象表示的字符序列相同。

示例:

"mesquite in your cellar".replace('e', 'o')
returns "mosquito in your collar"
"the war of baronets".replace('r', 'y')
returns "the way of bayonets"
"sparring with a purple porpoise".replace('p', 't')
returns "starring with a turtle tortoise"
"JonL".replace('q', 'x') returns "JonL" (no change)

參數(shù):
oldChar - 原字符。
newChar - 新字符。
返回:
一個(gè)從此字符串派生的字符串,它將此字符串中的所有 oldChar 替代為 newChar。



查看完整回答
反對(duì) 回復(fù) 2021-07-05
?
一只名叫tom的貓

TA貢獻(xiàn)1906條經(jīng)驗(yàn) 獲得超3個(gè)贊

class metho {
public metho() {
}

public static void main(String[] args) {
String firstString = "This is";
String secondString = "Thisis";
if (firstString.equals(secondString)) {
System.out.println("相等");}
else{
System.out.println("不相等");
}
System.out.println(firstString.concat(" hisfather"));
System.out.println(firstString.replace(firstString.lastIndexOf('i'),'z' ));
}
}



查看完整回答
反對(duì) 回復(fù) 2021-07-05
  • 2 回答
  • 0 關(guān)注
  • 246 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)