16.9 Calling Methods and Accessing Properties
Now is probably a good time to recap what we have done so far in this chapter. We have now created a new Kotlin class named BankAccount. Within this new class we declared primary and secondary constructors to accept and initialize account number, balance and customer name properties. In the preceding sections we also covered the steps necessary to create and initialize an instance of our new class. The next step is to learn how to call the instance methods and access the properties we built into our class. This is most easily achieved using dot notation.
Dot notation involves accessing a property, or calling a method by specifying a class instance followed by a dot followed in turn by the name of the property or method:
classInstance.propertyname
classInstance.methodname()
For example, to get the current value of our accountBalance instance variable:
val balance1 = account1.accountBalance
Dot notation can also be used...