给定两个字符串base和remove,返回基本字符串的一个版本,其中删除字符串的所有实例都已被删除(不区分大小写)。您可能会认为删除字符串的长度为1或更多。只删除不重叠的实例,所以用“xxx”删除“xx”留下“x”。如何删除部分字符串
withoutString("Hello there", "llo") → "He there"
withoutString("Hello there", "e") → "Hllo thr"
withoutString("Hello there", "x") → "Hello there"
为什么我不能使用此代码:
public String withoutString(String base, String remove)
{
base.replace(remove, "");
return base;
}
我没有得到,为什么人们投票了这个问题..:P – 2014-12-04 12:37:50