Amitabha Batranab
In the Above code, I used an object of class Dog as a key. My question is in class Dog, I didnt ovveride the equals() and the hashcode(). I realize this should compile and run nonetheless but shouldnt the last output give me a null as a result of that??
Instead it is showing me the value associated with d1.
output:
hello world - String's default method is toSting(), which prints it's value.
Same way:
out.println(m.get(d1)); returns object refernced to
d1 that is
"Dog Key"; and this is String object having toString() as default method; toString() prints value of String object.