Kotlin getters and setters
Getters and setters are a similar case to what happens with the primary constructor when it is used by default. This means that by default, we don’t have to do anything extra. Kotlin creates the code for us; we just have to know that it exists in order to use it. get and set are generated, which reduces the use of code when creating the base of our project. We don’t have to do anything and already have the corresponding Get and Set methods.
We have already seen the Java code of the Book class. Let’s make the equivalent code with get and set and a constructor in Kotlin:
class Book(var title: String, var author: String, var isbn: String, var pages: Int)
    In this example, we can see the great advantage of Kotlin. In a single line, we are doing what we did before, but using fewer lines. Let’s break this down to make it clearer:
- We are defining a 
Bookclass. - We place a primary constructor when placing properties...