Variables
We can think of a variable as a named storage box. We choose a name, perhaps variableA
. These names are the programmer's access into the memory of the user's Android device.
Variables are values in memory that are ready to be used when necessary by referring to them with their name.
Computer memory has a highly complex system of addresses that, fortunately, we do not need to directly interact with. Kotlin variables allow us to devise our own convenient names for all the data that we need our app to work with. The operating system will, in turn, interact with the physical (hardware) memory.
So, we can think of our Android device's memory as a huge warehouse waiting for us to add our variables. When we assign names to our variables, they are stored in the warehouse, ready for when we need them. When we use our variable's name, the device knows exactly what we are referring to. We can then tell it to do things, such as the following:
Assign a value to
variableA
Add
variableA
tovariableB...