public class String1
{
public static void sop (String str)
{
System.out.println(str);
}
public static void main(String[] args)
{
String s = " avb afa ";
sop(s);
s=f(s);
sop(s);
}
public static String f(String str) //此处报错 This method must return a result of type 我这里应该是返回了一个String类型
String
{
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);
}
} |
|