Two Laptop Bag
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Using HashMap Problem 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 "Using HashMap Problem" Watch "Using HashMap Problem" New topic

Using HashMap Problem

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

KB book

1.what does does ?

2.can anyone explain why
#1 gives complie-time error
#2, works fine
#3 gives complie time error

In the last line of code,

The complier is comparing arthur length with clover length.
my question is why is it not comparing the length of name clover passed in the object (new Dog("clover") with that kept in the hashmap.

the hashmap holds d1 with Dog key
where d1 is the key and Dog Key is the value.
here d1 is

OCPJP 6.0 93%
OCPJWCD 5.0 98%
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Please QuoteYourSources.

[My Blog]
All roads lead to JavaRanch
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Change the name length of d1 and check....Like this....

|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

see the changes
I agree. Here's the link:
subject: Using HashMap Problem
It's not a secret anymore!