What is difference between hash mapping and hash table?

Answer Posted / khalid

Both provide key-value access to data. The Hashtable is one
of the original collection classes in Java. HashMap is part
of the new Collections Framework, added with Java 2, v1.2.
The key difference between the two is that access to the
Hashtable is synchronized on the table while access to the
HashMap isn't. You can add it, but it isn't there by
default.

Another difference is that iterator in the HashMap is fail-
safe while the enumerator for the Hashtable isn't. If you
change the map while iterating, you'll know.

And, a third difference is that HashMap permits null values
in it, while Hashtable doesn't.

For new code, I would tend to always use HashMap.

Is This Answer Correct ?    0 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between printf and scanf?

510


Is java pass by value or pass by reference?

532


What are the main uses of the super keyword?

547


How is garbage collection controlled?

725


Can we declare a constructor as final?

669






What are the differences between this and super keyword?

521


What is protected in java?

517


How big is a boolean?

569


what is the purpose of using rmisecuritymanager in rmi?

558


What method is used to specify a container's layout in java programming?

534


What is the meaning of I ++ in java?

598


What is an image buffer?

531


Does anyone still use java?

575


What is the difference between the boolean & operator and the && operator in java programming?

558


What is the difference between static method and instance method in Java?

560