String Y="part1 part2 part3",X="part1";
boolean foundMatch = false;
while(!foundMatch) {
foundMatch = Y.equals(X);
if(foundMatch) {
break;
}
else {
Y = useSplitToRemoveLastPart(Y);
if(Y.equals("")) {
break;
}
}
Run Code Online (Sandbox Code Playgroud)
// useSplitToRemoveLastPart()的实现
private static String useSplitToRemoveLastPart(String y) {
//What goes here .. It should chop the last part of the string..
return null;
}
Run Code Online (Sandbox Code Playgroud)
谁能帮忙......
Jig*_*shi 22
如果您希望删除part3并提供所有单词由空格分隔
String str ="part1 part2 part3";
String result = str.substring(0,str.lastIndexOf(" "));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15335 次 |
| 最近记录: |