aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt in collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt in collection" Watch "Doubt in collection" New topic
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in collection