Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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

what It means if you don't override equals()

 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I have a doubt in scjp pg 525(K&B)
The above code is the example for car/owner and equals(),hashcode().

question 1: for search I will be in trouble unless i still have a
reference to the exact object used as the key when added it to the
collection(may i know which object is that from the above code)

question 2: one instance added it to collection, essentially re-create
an identical instance to search based on the object as key.
does it mean like this?
car carobj1 = new car("V001Lexus");
Hm.put(carobj1, perobj1);
car carobj8 = new car("V001Lexus");
Hm.get(carobj8);

question 3: more than one object representing a single unique car can
exist( does this sentence mean this?)

Hm.put(carobj1,perobj1);
Hm.put(carobj1,perobj2);
Hm.put(carobj1,perobj3);
Hm.put(carobj1,perobj4);

which is something like overwriting different owner to the
same car

is my understanding right?


Thanks for your patience and valuable time for replying.

samura




 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If this link may help you!


Thanks,
 
aslika bahini
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
 
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic