【发布时间】:2018-11-16 23:54:32
【问题描述】:
public String removeStrings()
{
String cleaned = sentence; //sentence and remove are inputs
int loc = cleaned.indexOf(remove);
while (loc>-1) //need explanation on how this works
{
cleaned = cleaned.substring(0, loc-1)+cleaned.substring(loc+remove.length());
loc = cleaned.indexOf(remove);
}
return cleaned;
}
示例输入句="xR-MxR-MHelloxR-M" and remove="R-M" //在这种情况下也必须删除 x https://github.com/AndrewWeiler/AndrewMac/blob/master/ACSWeiler/src/Lab09/StringRemover.java
【问题讨论】: