class SrringTest
{
string sop(String str)
{
System.out.println(str);
}
public stctic void main(String [] args)
{
String s = " abc de ";
sop("("+s”)");
s = myTrim(s);
sop("("+s")");
}
public static String myTyim(String str)
{
int start = 0,end = str.length() - 1;
while(start<=end && str.charAt(start) == ' ')
start++;
while(start<=end && str.charAt(end) == ' ')
end--;
return str.substring(start,end+1);
}
}
去除字符串两端的空格
最新推荐文章于 2024-07-01 15:19:42 发布