Data Classes

Learn about data classes and how they differ from Java records.

We'll cover the following...

Remember that Kotlin is all about productiveness. One of the most common tasks for Java developers is to create yet another Plain Old Java Object (POJO). If you’re not familiar with POJO, it is basically an object that only has getters, setters, and implementation of equals or hashCode methods. This task is so common that Kotlin has it built into the language. It’s called a data class. Let’s take a look at the following example:

data class
...