| Author |
Doubt in collection
|
Lata Bagga
Ranch Hand
Joined: Jun 13, 2007
Posts: 35
|
|
which produces something like this: Dog@1c DOG CAT key Dog key null 5 If we add two lines of code to the end of the earlier MapTest.main(), d1.name = "magnolia" System.out.println(m.get(d1)); we get something like this: Dog@4 DOG CAT key Dog key null 5 null I am really confused why the output is "null" after setting d1.name="magnolia", I suppose the output should be "Dog key". I have compiled this code but still confused how it is working.
|
 |
Vishwanath Krishnamurthi
Ranch Hand
Joined: Jun 04, 2007
Posts: 331
|
|
Hi, Yes, it should print Dog Key and it does... I tried.. Guess you just forgot to save the changes before compiling again Regards, Vishwa
|
Blog
|
 |
sridhar row
Ranch Hand
Joined: Jan 16, 2008
Posts: 162
|
|
|
murthy are you sure??
|
 |
Vishwanath Krishnamurthi
Ranch Hand
Joined: Jun 04, 2007
Posts: 331
|
|
Hi Sridhar, After adding those lines, I'm pasting the o/p: Dog@4 DOG CAT key Dog key null 5 Dog key
|
 |
sridhar row
Ranch Hand
Joined: Jan 16, 2008
Posts: 162
|
|
|
Thanks Murthi, my bad ..my hashcode was returning name.length() which would be different for different names hence i was getting null..sorry abt the confusion.
|
 |
 |
|
|
subject: Doubt in collection
|
|
|