我知道没有简单的方法可以做到这一点。假设我有以下字符串-
"abcdefgh"
我想通过用'x'替换第三个字符'c'来获得一个字符串。
很长的路要走——
s1 = substring before third character = "ab" in this case
s2 = new character = "x" in this case
s3 = substring after third character = "defgh" in this case
finalString = s1 + s2 + s3
有没有更简单的方法?应该有一些功能,如
public String replace(int pos, char replacement)