Data classes with Default Constructors in Kotlin

February 12, 2019

While doing Java you will notice that there are a lot of classes that are just holding data, they don't have any methods other than getters and setters. This is why Kotlin has introduced a concept called Data Classes that do just that.

In addition, when creating data classes, you don't require a builder because you can have default values if the consumer does not supply the value.

data Person(val firstName: String = "Guest",
            val lastName: String = "")