0
我試圖在計算貸款金額的類中創建方法。該方法應該返回「totalPay」,但它是說它沒有被聲明,你明白爲什麼?在同一類中的dif方法中訪問值
public loan(double anualInterestRate, int numberOfYears, double loanAmount){
double base = (double) (loanAmount * (1+anualInterestRate/12));
double exponent = (double) (numberOfYears * 12);
double totalPay = (double) Math.pow(base, exponent);
}
總付款方式未看到「totalPay」出於某種原因:
/**
*
* @return total payment
*/
public double totalPayment(){
return totalPay;
}
我明白了!謝謝 :) – maribov