Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in collection

 
Lata Bagga
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 331
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
sridhar row
Ranch Hand
Posts: 162
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
murthy are you sure??
 
Vishwanath Krishnamurthi
Ranch Hand
Posts: 331
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 162
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic