java中sb.replace(5,6,",")中的参数什么意思
答案:2 悬赏:20 手机版
解决时间 2021-04-04 11:51
- 提问者网友:留有余香
- 2021-04-03 17:24
java中sb.replace(5,6,",")中的参数什么意思
最佳答案
- 五星知识达人网友:第四晚心情
- 2021-04-03 18:39
replace(char oldChar, char newChar)
返回一个新的字符串,它是通过用 newChar 替换此字符串中出现的所有 oldChar 而生成的。
public class TestReplace {
public static void main(String[] args) {
String s = "This is my original string ,it is very good!";
String r = "at";
s = s.replace("is",r);
System.out.println(s);
}
}
输出结果:
That is my original string ,it is very good!
返回一个新的字符串,它是通过用 newChar 替换此字符串中出现的所有 oldChar 而生成的。
public class TestReplace {
public static void main(String[] args) {
String s = "This is my original string ,it is very good!";
String r = "at";
s = s.replace("is",r);
System.out.println(s);
}
}
输出结果:
That is my original string ,it is very good!
全部回答
- 1楼网友:蓝房子
- 2021-04-03 19:53
变量sb是什么类型的。。。。。。。。。。。。。
是StringBuilder?
StringBuilder
replace(int start,
int end,
String str)
Replaces the characters in a substring of this sequence
with characters in the specified String.
是StringBuilder?
StringBuilder
replace(int start,
int end,
String str)
Replaces the characters in a substring of this sequence
with characters in the specified String.
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯