Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using HashMap Problem

 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
KB book





1.what does d1.name does ?

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

3.
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
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please QuoteYourSources.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change the name length of d1 and check....Like this....
 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see the changes
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic