that will call the toString method of the object mapped to the key k1. If toString is not overridden for an object, you will get that "hash"
string. So, your Dog object needs to override toString()
maps the key d1 to a String containing "Dog key" , so no surprise that it prints the string.
Pets.DOG is just a string, so it prints the string