June 2018
Intermediate to advanced
310 pages
6h 32m
English
Remember how Kotlin is all about productiveness? One of the most common tasks for Java developers is to create another Plain Old Java Object (POJO). If you're not familiar with POJO, it is basically an object that only has getters, setters, and an implementation of equals or hashCode methods.
This task is so common that Kotlin has it built into the language:
data class User (val username : String, val password : String)
This will generate a class with two getters and no setters (note the val part), which will also implement equals, hashCode, and clone functions in the correct way.
The introduction of data classes is one of the biggest improvements in reducing the amount of boilerplate in the language.
Read now
Unlock full access