Skip to content

Instantly share code, notes, and snippets.

@schroedermatt
Last active August 2, 2018 18:42
Show Gist options
  • Select an option

  • Save schroedermatt/62e4aa3ae508910945e9ddffd74b301f to your computer and use it in GitHub Desktop.

Select an option

Save schroedermatt/62e4aa3ae508910945e9ddffd74b301f to your computer and use it in GitHub Desktop.
java pojo vs kotlin data class
// 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