how do I get the same hashCode from an object whic...
# android
s
how do I get the same hashCode from an object which is shown in the default
toString()
representation? testing a scratch file, all variants produce different hash codes and none matches the one from toString
Copy code
class Foo
val foo = Foo()

foo.toString()              Foo@12f40c25
foo.hashCode()              317983781
foo::javaClass.hashCode()   405143212    
foo::class.java.hashCode()  428746855
a
It's a hex representation of the hashCode()
Copy code
foo.hashCode().toString(16)
👀 1
s
ah sure, should have seen that on the types: int vs hex thank you very much!