A string doesn't have an encoding - or it's always UTF-16, if you want to think of it like that. There's no such thing as "a UTF8 string". If you've converted some binary data into a String using the wrong encoding, you're in trouble already
Hash maps only use hash codes to find keys efficiently. When you ask the map to find a value, it basically has to iterate over all its entries, at which point there's no point in using
hashCode()
, so it just calls equals
.
If you try the map the other way round, with
Test
as the key instead of the value, that won't work without overriding hashCode
.
No comments:
Post a Comment