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*
是不是意思就是返回的是第一次的返回值?
墨色风雨
开心每一天1111
相关分类