0
public class Welcome {
public class OperationFactory {
public static Operation createOperate(String operate) {
Operation operation = null;
if("+".equalsIgnoreCase(operate)) {
operation = new OperationAdd();
}else if("-".equalsIgnoreCase(operate)) {
operation = new OperationSub();
}else if("*".equalsIgnoreCase(operate)) {
operation = new OperationMul();
}else {
operation = new OperationDiv();
}
return operation;
}
}
}
问题是:方法createOperate不能声明为静态;静态方法只能在静态或顶级类型中声明 我不知道如何解决。谢谢createOperate方法不能被声明为静态;静态方法只能在静态或顶级类型中声明