Last active
August 2, 2018 18:42
-
-
Save schroedermatt/62e4aa3ae508910945e9ddffd74b301f to your computer and use it in GitHub Desktop.
java pojo vs kotlin data class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // kotlin data class (equals/hashcode/copy available) | |
| data class Song (val name: String, val artist: Artist, var length: Int?) | |
| // pojo with 1 of the Song properties for brevity (and no equals/hashcode) | |
| public class Song { | |
| private String name; | |
| public Song(String name) { | |
| this.name = name; | |
| } | |
| public String getName() { | |
| return name; | |
| } | |
| public void setName(String name) { | |
| this.name = name; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment