Replace with empty string replaces newChar around all the characters in original string

前端 未结 4 1496
甜味超标
甜味超标 2021-01-20 07:13

I was just working on one of my java code in which I am using Java String.replace method. So while testing the replace method as in one situation I am planning to put junk v

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-20 07:46

    replace looks for each place that you have a String which starts with the replaced string. e.g. if you replace "a" in "banana" it finds "a" 3 times.

    However, for empty string it finds it everywhere including before and after the last letter.

提交回复
热议问题