下面这段代码看了好几次,没找出问题在哪,编译失败。
class StringDemo
{
public static void main(String[] args)
{
String s = " slien ";
s = clearBlank(s);
System.out.println(s);
}
public static String clearBlank(String s)
{
int first = 0;
int last = s.length()-1;
while (first<=last && s.charAt(first)==' ')
first++;
while (first<=last && s.charAt(last)==' ')
last++;
return s.substring(first,last+1);
}
}
|