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方法不能被聲明爲靜態;靜態方法只能在靜態或頂級類型中聲明