answersLogoWhite

0

Hash table in java

Updated: 8/19/2019
User Avatar

Wiki User

13y ago

Best Answer

HashMap

The HashMap gives you an unsorted, unordered Map. When you need a Map and you don't care about the order (when you iterate through it), then HashMap is the way to go; the other maps add a little more overhead. Where the keys land in the Map is based on the key's hashcode, so, like HashSet, the more efficient your hashCode() implementation, the better access performance you'll get. HashMap allows one null key and multiple null values in a collection.

HashTable

Like Vector, Hashtable has existed from prehistoric Java times. For fun, don't forget to note the naming inconsistency: HashMap vs. Hashtable. Where's the capitalization of t? Oh well, you won't 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 don't 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 doesn't let you have anything that's null.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Hash table in java
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are the methods of hash table?

See the related link below for the Java API documentation for the Hashtable class and its methods.


What is hash key?

hash key is an element in the hash table. it is the data that you will combine (mathematical) with hash function to produce the hash.


What is hash table in sql?

temp table


What is the major advantage of a hash table?

The major advantage of a hash table is its speed. Because the hash function is to take a range of key values and transform them into index values in such a way that the key values are distributed randomly across all the indices of a hash table.


What is HashMap Java used for?

HashMap Java is used as a definition in Java software programming language. This version of Java is used to tag objects using hash numbers and therefore differentiate different items in different databases.


Why does java have a coffee table as icon?

Java is one of the slang terms for coffee.


What is the maximum number of entries that can be placed in the chained hash table?

There is no upper limit.


What is a hash function in java?

http://www.partow.net/programming/hashfunctions/ please refer this website. i think its the best so far


Advantage and distadvantage in hash table?

ANSWER A hash table is a way to find data in an array, when you have a known key and an unknown value that corresponds to the key. You use a hashing function on the key to create an index into the hash table containing the value. In the ideal case, this directly returns the corresponding value. In the usual case, a collision can occur. This means that the hashed key points to multiple possible values. A hash table is usually used on large arrays that would take a long time to search using other methods. A hash table can be very fast and use very little memory, and does not require the array to be sorted. The source code is slightly more complicated than some search methods. With a poorly designed hashing function when the hashed keys do not correspond one-to-one with the values, the secondary search after a hash collision can take a large amount of time.


Insert value into hash table?

Insertion in hash tables is based on a 'key' value which is calculated on the basis of a hash function. This hash function generates the key based on what type of data it is fed. For example hash function for an integer input might look like this : int hash(int val) { return (val%101); } where return value of hash function would become a key. Complete implementation can be found at: http://simplestcodings.blogspot.com/2010/07/hash-table.html


How do you use hash table?

In computer science, a hash table, or a hash map, is a data structure that associates keys with values. The primary operation it supports efficiently is a lookup: given a key (e.g. a person's name), find the corresponding value (e.g. that person's telephone number). It works by transforming the key using a hash function into a hash, a number that is used as an index in an array to locate the desired location ("bucket") where the values should be. Hash tables support the efficient insertion of new entries, in expected O(1) time. The time spent in searching depends on the hash function and the load of the hash table; both insertion and search approach O(1) time with well chosen values and hashes.


Table manners in java Indonesia?

go say hi