1
輸出示例:Java方法存根錯誤
FIXME:完成getUserNum()
FIXME:完成getUserNum()
FIXME:完成computeAvg()
平均:-1
代碼我有:
public class MthdStubsStatistics {
public static int getUserNum() {
System.out.println("FIXME: Finish getUserNum()");
return -1;
}
public static Integer computeAvg(){
System.out.println("FIXME: Finish computeAvg()");
return -1;
}
public static void main() {
int userNum1 = 0;
int userNum2 = 0;
int avgResult = 0;
userNum1 = getUserNum();
userNum2 = getUserNum();
avgResult = computeAvg(userNum1, userNum2);
System.out.println("Avg: " + avgResult);
return;
}
}
我遇到的問題是computeavg方法是給我這個錯誤:
MthdStubsStatistics.java:23: computeAvg() in MthdStubsStatistics cannot be applied to (int,int) avgResult = computeAvg(userNum1, userNum2);
'computeAvg'不接受任何參數,您不能使用參數調用它。 – Berger
當你遇到你不明白的異常時,嘗試創建一個[mcve]。這將幫助您追蹤到底是什麼問題,並使其他人更容易幫助您解決問題。 –
好,非常感謝 – BMajowicz