Hullaballoonatic
09/11/2018, 10:39 PMTaras Koshkin
09/11/2018, 11:01 PMequals()
just compares if the object reference is the same which isn't really that useful, so you have to override hashCode()
so that it compares if the values inside are the same or not. It's also used in Collections a lot. Most IDEs come with equals
and hashCode
generators. Also Kotlin's data classes implement these by default, so for those you don't need to override.Sam
09/11/2018, 11:25 PM