JDK1.5中String.replace()的实现有点奇怪
最近在看JDK1.5的源码,看到String.replace()的时候,有点不明白,和大家分享一下:
"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)
参数:
oldChar - 原字符。
newChar - 新字符。
返回:
一个从此字符串派生的字符串,它将此字符串中的所有 oldChar 替代为 newChar。
[其他解释]
路过顶一下!!!
[其他解释]
刚换了头像 来看看帅不帅!
[其他解释]