• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

K&B pg 563 Maps

 
Ranch Hand
Posts: 278
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Maps ,
I create a class according to book ,and overrode hashCode() ,equals () to use objects as keys as according to page 563
My,
hashCode() returns length of String.
equals() tests String-variable's equality(only 1 var)

Now after put()ng one key,value
when i change the key-objects variables ..its value should not be .
accessible using get(key)
If value ->changed to same length string,hashCode wd be same,but equals should fail and VAlue wont be found.

In my case, after modifying to different length string o/p is correct ,NULL
but same lenght should also be null as equals() fails ...but its picking value.


can you help me understing it if its all right & why its correct

thank you
 
reply
    Bookmark Topic Watch Topic
  • New Topic