- Examples
Here are a few examples of the different types of methods that we explored in the previous lesson.
We'll cover the following...
We'll cover the following...
Static methods #
Explanation #
-
The static attribute,
deposits, is being initialized on line 8. Whenever the constructor is called, its value is incremented by1. -
On lines 22 and 29, we can see that the static
getDeposits()method can be called without an instance ofAccount. -
After the creation of
account1andaccount2, the value ofdepositsis incremented to2. We can check this by invokinggetDeposits()...