Kotlin Data Class vs Java Boilerplate
data class Person(val name: String) private String name; public Person(String name) { this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } // toString... // hashCode... // equals... // copy...
A comparison shows Kotlin’s concise data class declaration beside the verbose Java code required to define the same Person class with a field, constructor, getters, setters, and generated methods. The joke is that Kotlin eliminates repetitive boilerplate, making Java look unnecessarily cumbersome to programmers.
- @profunctor_io / 2669 2019-07-19
- Type
- image
- Size
- 800×376 · 20.3 KiB
- Mood
- sarcastic
- Language
- en
- Added