Basic classes app and using the init block
You can get the completed code for this app in the code download. It is in the Chapter10/Basic Classes
folder. But it is most useful to read on to create your own working example.
We will create a few different classes using what we have learned throughout this chapter to put the theory in to practice. We will also see our first example of how classes can interact with each other by passing a class as a parameter into the function of another class. We know how to do this in theory already, we just haven't seen it in practice yet.
We will also see another way to initialize our data when the class is first instantiated by using an init
block.
We will create a small app that plays with the idea of simulating ...
Get Android Programming with Kotlin for Beginners now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.