String deal(String s1, String s2){if(s1 != null){if(contact(s1.charAt(s1.length() - 1)) == 1){s1 += s2;return s1;}else{s1 = s1.substring(0, s1.length() - 1);deal(s1, s2);}}return s1;}int contact(char ch){if(Character.isDigit(ch) || ch == *(* || ch == *)* || ch == *.*)return 1;if(ch == *-* || ch == *+*)return 2;return 0;}String str = deal("800", "*");这样就返回的是800*如果String str = deal("800-", "*");返回的是800,不是800*是不是意思就是返回的是第一次的返回值?
2 回答

墨色风雨
TA贡献1853条经验 获得超6个赞
public static String deal(String s1, String s2)
{
if(s1 != null)
{
if(contact(s1.charAt(s1.length() - 1)) == 1)
{
s1 += s2;
return s1;
}
else
{
s1 = s1.substring(0, s1.length()-1 );
String a = deal(s1, s2);
if(a!=""||!a.equals("")){
return a;
}
}
}
这样改就成了
添加回答
举报
0/150
提交
取消