File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question in Map 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 "Question in Map" Watch "Question in Map" New topic

Question in Map

Mebi Mathew

Joined: Jul 19, 2010
Posts: 4

I am new to JavaRanch

Can anyone please explan the following code

The output of line 1 is raju
The output of line 2 is null.

My question is why line 1 is giving the output as raju
Sahil Kapoor
Ranch Hand

Joined: Sep 12, 2009
Posts: 316

1. Your hashcode implementions allows for searching the same bucket.
2. Your equal method returns true as the compared object and object stored are referring to the same object.

If you do the following

Dog d= new Dog("arthur");

then it would return null iff Orginal Dog's name has not been changed to "arthur".


SCJP 6.0 96%

(Connecting the Dots ....)
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

First, have a look on here, to know how the Map works!

Clue : Change the length of your Dog's name, then get the value pair with those objects! For example

|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
I agree. Here's the link:
subject: Question in Map
It's not a secret anymore!