non-static method

LIUYIXIN Reply 4 years 50 weeks ago
non-static method ....cannot be refernced from a static content.
withcs2 Reply 4 years 50 weeks ago
Account.setAnnualInterestRate is different from account.setAnnualInterestRate. I recommend you to study "static" All accounts have the same interest rate. --> If every account has its own annualInterestRate, it's waste of memory. (declare annualInterestRate as default) --> It's better to store annualInterestRate only once regardless of the number of accounts. (declare annualInterestRate as static) That's why the sample code declared Account.setAnnualInterestRate instead of account.setAnnualInterestRate.