Amazon Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: Phone Interview
apart from syncronisation and null value, are there any differences between hashmap and hashtable???
Rgds,
Sriraam
Apart from Sync and null value:
HashMap can be typecasted to LinkedHashMap..and it will preserve the order of insertion of elements into the map..Where, a simple hash returns the elements in a random fashion....HashTable doesnt have this support.
HashMap and HashTable are datastructures that implement dictionary (insert, remove, search) operations, using a hash funtion to identify the position of the key.
- Jaiprakash April 03, 2012HashTable is synchronized while hash map is not. Also, hash map allows null values.
If we have a bad hashing algorithm, the time taken to search is O(n) instead of O(1) which is provided by a good hashing algorithm.
The values are stored in an array in java.