标题: 代码错误不会改 [打印本页] 作者: xgd6612 时间: 2015-5-6 09:36 标题: 代码错误不会改 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);