Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Java in General
hashtable working & overriding equals()
Joined: Feb 26, 2005
Mar 22, 2005 01:01:00
thanx for the tremendous response for clearing my earlier doubt in string-pool.expecting similar responses from u all,i m posting yet another question and its regarding hashtable working.
we know that hashtable stores values as key/value pairs,where both key and value should b an object.
considering this code,
public static void main(
car ob1=new car();
car ob2=new car();
Hashtable hs=new Hashtable();
}//end of main
}// end of class car
now the o/p obtained is Rahi.i understand why is it so.as i have reffered the key ob1 for Rahi at last.
i want to know how the hashtable retreives the data,and how can i override equals() method,so that key/value pair is unique.
please give thw way as how i should override the equals() method to make my code more efficient.
author and iconoclast
Joined: Jul 08, 2003
Mar 22, 2005 05:20:00
Please don't post
It just wastes people's time if they answer a question that's already been answered elsewhere. I'm closing this one.
[Jess in Action]
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
subject: hashtable working & overriding equals()
hashtable working & overriding equals
a doubt in equals() method
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014