给定两个字符串base和remove,返回基本字符串的一个版本,其中删除了删除字符串的所有实例(不区分大小写).您可以假设删除字符串的长度为1或更长.仅删除不重叠的实例,因此使用"xxx"删除"xx"会留下"x".
withoutString("Hello there", "llo") ? "He there"
withoutString("Hello there", "e") ? "Hllo thr"
withoutString("Hello there", "x") ? "Hello there"
Run Code Online (Sandbox Code Playgroud)
为什么我不能使用这段代码:
public String withoutString(String base, String remove)
{
base.replace(remove, "");
return base;
}
Run Code Online (Sandbox Code Playgroud) 我在学习c时仍然知道,我面临以下问题.
我试图初始化并声明一个数组但它给我编译错误.
const int a =2;
int x[a]={2};
Run Code Online (Sandbox Code Playgroud)