Wednesday, February 7, 2007 03:00 AM
I used to get the same question, whenver I thought of HashTable. The concept is actually, a little difficult to understand for beginners(and more complex for ppl with non-it background).All that stuff related to hashCode() and equals() methods. Forget this for now, as it is fairly low level concept, at this age of Java.
Read this excerpt from the JCP material:
"Like Vector, Hashtable has been in from prehistoric Java times. For
fun, dont forget to note the naming inconsistency: HashMap vs. Hashtable. Wheres
the capitalization of t? Oh well, you wont be expected to spell it. Anyway, just as
Vector is a synchronized counterpart to the sleeker, more modern ArrayList, Hashtable
is the synchronized counterpart to HashMap. Remember that you dont synchronize a
class, so when we say that Vector and Hashtable are synchronized, we just mean that
the key methods of the class are synchronized. Another difference, though, is that
while HashMap lets you have null values as well as one null key, a Hashtable doesnt
let you have anything thats null."