Date post: | 14-Apr-2018 |
Category: |
Documents |
Upload: | yogananda-yallam |
View: | 222 times |
Download: | 0 times |
of 20
7/30/2019 Java Hashtable
1/20
5/15/13 Java Hashtable
javapapers.com/core-java/java-hashtable/
Java Hashtable
17/08/2011
Hashtable is an implementation of a key-value pair data structure in java. You can store and retrieve a value
using a key and it is an identifierof the value stored. It is obvious that the key should be unique.
java.util.Hashtable extends Dictionary and implements Map. Objects with non-null value can be used as a key or
value. Key of the Hashtable must implement hashcode() and equals() methods. By the end of this article you will
find out the reason behind this condition.
Generally a Hashtable in java is created using the empty constructorHashtable(). Which is a poor decision and
an often repeated mistake. Hashtable has two other constructors
and
. Initial capacity is number of buckets created at the time of Hashtable instantiation. Bucket is a logical space of
Hashtable(intinitialCapacity)
Hashtable(intinitialCapacity, floatloadFactor)
http://javapapers.com/http://javapapers.com/http://javapapers.com/http://javapapers.com/core-java/java-double-brace-initialization/http://javapapers.com/core-java/nullpointerexception-null-bad-good-and-ugly/http://javapapers.com/core-java/how-many-types-of-java-variables-are-there/http://javapapers.com/7/30/2019 Java Hashtable
2/20
5/15/13 Java Hashtable
javapapers.com/core-java/java-hashtable/ 2
storage for Hashtable.
Hashing and Hashtable
Before seeing javas Hashtable in detail you should understand hashing in general. Assume that, v is a value to be
stored and k is the key used for storage / retrieval, then h is a hash function where v is stored at h(k) of table. To
retrieve a value compute h(k) so that you can directly get the position of v. So in a key-value pair table, you need
not sequentially scan through the keys to identify a value.
h(k) is the hashing function and it is used to find the location to store the corresponding value v. h(k) cannot
compute to a indefinite space. Storage allocated for a Hashtable is limited within a program. So, the hasing
function h(k) should return a number within that allocated spectrum (logical address space).
Hashing in Java
Javas hashing uses uses hashCode() method from the key and value objects to compute. Following is the core
code from Hashtable where the hashCode h is computed. You can see that both keys and values hashCode(method is called.
It is better to have your hashCode() method in your custom objects. String has its own hashCode methode and i
computes the hashcode value as below:
If you dont have a hashCode() method, then it is derived from Object class. Following isjavadoc comment of
hashCode() method from Object class:
If you are going to write a custom hashCode(), then follow the following contract:
The following is to improve performance of the Hashtable.
h += e.key.hashCode() ^ e.value.hashCode();
s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
* Returns a hash code value forthe object. This method is * supported forthe benefit of hashtables such as those provided by * java.util.Hashtable.
* The general contract of hashCode is: * * Whenever it is invoked on the same object more than once during
* an execution of a Java application, the hashCode method * must consistently returnthe same integer, provided no informatio * used in equals comparisons on the object is modified.
* If two objects are equal according to the equals(Object) * method, then calling the hashCode method on each of * the two objects must produce the same integer result.
http://javapapers.com/core-java/is-javadoc-comment-a-type-of-standard-java-comment/http://javapapers.com/core-java/java-string-concatenation/http://javapapers.com/core-java/java-jvm-memory-types/http://javapapers.com/core-java/java-jvm-memory-types/7/30/2019 Java Hashtable
3/20
5/15/13 Java Hashtable
javapapers.com/core-java/java-hashtable/ 3
hashCode() guarantees distinct integers by using the internal address of the object.
Collision in Hashtable
When we try to restrict the hashing functions output within the allocated address spectrue limit, there is a
possibility of a collision. For two different keys k1 and k2, if we have h(k1) = h(k2), then this is called collision in
hashtable. What does this mean, our hashing function directs us store two different values (keys are also
different) in the same location.
When we have a collision, there are multiple methodologies available to resolve it. To name a few hashtable
collision resolution technique, separate chaining, open addressing, robin hood hashing, cuckoo hashing,
etc. Javas hashtable uses separate chaining for collision resolution in Hashtable.
Collision Resolution in javas Hashtable
Java uses separate chaining for collision resolution. Recall a point that Hashtable stores elements in buckets. In
separate chaining, every bucket will store a reference to a linked list. Now assume that you have stored anelement in bucket 1. That means, in bucket 1 you will have a reference to a linked list and in that linked list you
will have two cells. In those two cells you will have key and its corresponding value.
Why do you want to store the key? Because when there is a collision i.e., when two keys results in samehashcode and directs to the same bucket (assume bucket 1) you want to store the second element also in the
same bucket. You add this second element to the already created linked list as the adjacent element.
Now when you retrieve a value it will compute the hash code and direct you to a bucket which has two
elements. You scan those two elements alone sequentially and compare the keys using their equals() method.
When the key mathches you get the respective value. Hope you have got the reason behind the condition that
your object must have hashCode() and equals() method.
Java has a private static class Entry inside Hashtable. It is an implementation of a list and you can see there, it
7/30/2019 Java Hashtable
4/20
5/15/13 Java Hashtable
javapapers.com/core-java/java-hashtable/ 4
stores both the key and value.
Hashtable performance
To get better performance from your java Hashtable, you need to
1) use the initialCapacity and loadFactor arguments
2) use them wisely
while instantiating a Hashtable.
initialCapacitiy is the number of buckets to be created at the time of Hashtable instantiation. The number of
buckets and probability of collision is inversly proportional. If you have more number of buckets than needed
then you have lesser possibility for a collision.
For example, if you are going to store 10 elements and if you are going to have initialCapacity as 100 then you
will have 100 buckets. You are going to calculate hashCoe() only 10 times with a spectrum of 100 buckets. The
possibility of a collision is very very less.
But if you are going to supply initialCapacity for the Hashtable as 10, then the possibility of collision is very largeloadFactor decides when to automatically increase the size of the Hashtable. The default size of initialCapacity is
11 and loadFactor is .75 That if the Hashtable is 3/4 th full then the size of the Hashtable is increased.
New capacity in java Hashtable is calculated as follows:
If you give a lesser capacity and loadfactor and often it does the rehash() which will cause you performance
issues. Therefore for efficient performance for Hashtable in java, give initialCapacity as 25% extra than you need
and loadFactor as 0.75 when you instantiate.
Ads by Google
intnewCapacity = oldCapacity * 2+ 1;
http://www.googleadservices.com/pagead/aclk?sa=L&ai=CbVs4Az-TUbzbNKzFigefjIDADfiNzNkDwK3ynDqI86HAtQEQASD4iPkFUJKjs_38_____wFg5crlg7QOoAHQm9PkA8gBAqkC6PwG_tmZUz6oAwHIA9EEqgSGAU_QkOTsAn8foKyETFlWsUKDA0qY6Dg8FN9YwdMXJYqxDavb7DvO8QRmlQDSBmlE2jgV5le8J66b5sXgNCG2sB5Hl4DrmjtCt_uk8ElHS60it1P3O7E0HwrDkjBY1LRDIBoKMnZw0wz9eQgQs1QtU7f8JUm-KirO2BSlssfyzVMa_1Xw7OvZiAYBoAYCgAeY5Kwb&num=1&cid=5GjdA54xfjFaq7SRukX2yxPm&sig=AOD64_0DZsf5mQJCa9IcODfPSPxibTfAdw&client=ca-pub-2525233393528874&adurl=http://www.kotaksecurities.com/landingpage/tradingsoftware/keatproxg.jsp%3Futm_source%3Dgoogle%26utm_medium%3Dcpc%26utm_campaign%3DGDN%2B-%2BRemarketing%2B-%2BImage%2B-%2B1%26utm_term%3D%26utm_kw%3D&nm=27/30/2019 Java Hashtable
5/20
5/15/13 Java Hashtable
javapapers.com/core-java/java-hashtable/ 5
PREV: Decorator Design Pattern
NEXT: Java String
101 comments on Java Hashtable
1. joshi said on 17/08/2011,
if youre really interested in performance you should stick to hashmap if multithreading is no issue. You
really should add a section about Hastable vs. Hashmap in this article
Reply
2. Joe said on 17/08/2011,
yes Joshi you are right. Between Hashtable and Hashmap, Hashmap is preferred in non-threaded
environment.
When you are forced to use Hashtable, consider these performance tips.
Sure I will come up with an article about Hashtable vs Hashmap.
Reply
3. Tito said on 18/08/2011,
good info. keep posting. can u write some info on the DAO patterns.
Reply
4. Jigar Joshi said on 18/08/2011,
Nicely explained..!
See About : Hash Table VS HashMap :http://stackoverflow.com/questions/40471/java-hashmap-vs-
hashtable
Reply
5. Jigar Joshi said on 18/08/2011,
and implementation of hashCode for String is
h = 31*h + val[off++];
in standard jdk 6 & 7
http://javapapers.com/core-java/java-hashtable/#comment-7180http://javapapers.com/core-java/java-hashtable/?replytocom=7179#respondhttp://stackoverflow.com/questions/40471/java-hashmap-vs-hashtablehttp://javapapers.com/core-java/java-hashtable/#comment-7179http://javapapers.com/core-java/java-hashtable/?replytocom=7178#respondhttp://javapapers.com/core-java/java-hashtable/#comment-7178http://about.me/titohttp://javapapers.com/core-java/java-hashtable/?replytocom=7172#respondhttp://javapapers.com/core-java/java-hashtable/#comment-7172http://javapapers.com/http://javapapers.com/core-java/java-hashtable/?replytocom=7171#respondhttp://javapapers.com/core-java/java-hashtable/#comment-7171http://javapapers.com/core-java/java-string/http://javapapers.com/design-patterns/decorator-pattern/7/30/2019 Java Hashtable
6/20
5/15/13 Java Hashtable
javapapers.com/core-java/java-hashtable/ 6
Reply
6. Jacob said on 18/08/2011,
See this also ,,http://stackoverflow.com/questions/6493605/how-does-java-hashmap-work
Reply
7. Dev Ghotkule said on 18/08/2011,
Most use full information.
Reply
8. Praveen said on 18/08/2011,
Good article after a long time
Kindly start posting on JEE6 features.
Reply
9. Madhusudhan said on 18/08/2011,
Great. Clear & Simple. Thank you.
Reply
10. KiranJyothi said on 18/08/2011,
It is very nice and clear. Can you take some real time examples and explain (like yellow pages). That
would be great!!
Thank you for this post!!
Cheers,
Jyothi
Reply
Ads by Google
http://javapapers.com/core-java/java-hashtable/?replytocom=7196#respondhttp://javapapers.com/core-java/java-hashtable/#comment-7196http://kiranjyothi.webs.com/http://javapapers.com/core-java/java-hashtable/?replytocom=7192#respondhttp://javapapers.com/core-java/java-hashtable/#comment-7192http://firewallsudhan.com/http://javapapers.com/core-java/java-hashtable/?replytocom=7189#respondhttp://javapapers.com/core-java/java-hashtable/#comment-7189http://codewithcoffee.wordpress.com/http://javapapers.com/core-java/java-hashtable/?replytocom=7186#respondhttp://javapapers.com/core-java/java-hashtable/#comment-7186http://javapapers.com/core-java/java-hashtable/?replytocom=7181#respondhttp://stackoverflow.com/questions/6493605/how-does-java-hashmap-workhttp://javapapers.com/core-java/java-hashtable/#comment-7181http://javapapers.com/core-java/java-hashtable/?replytocom=7180#respond7/30/2019 Java Hashtable
7/20
5/15/13 Java Hashtable
javapapers.com/core-java/java-hashtable/ 7
11. shashi said on 24/08/2011,
nice artical
Reply
12. shyam said on 24/08/2011,
this kind of explanation is clear
Reply
13. Born said on 25/08/2011,
Hashtable is preferred in non-threaded environment. you mixed it up? ;) hashtable is the
synchronized version, so use hashmap instead, if multi-threading is not needed. And besides one should
always consider the synchronizedXYZ Methods of the Collections class instead of using special
synchronized Collection types. So use: Collections.synchronizedMap if you want a synchronized version
of HashMap.
But nevertheless the theory the blog post is talking about is of course the same for the hashmap andconsidered as useful information ;)
Reply
14. Joe said on 25/08/2011,
Oops! Born, thats a typo (very costly one) :0 I have fixed it. Thanks for pointing out.
Reply
15. Anjali said on 07/09/2011,
Nice article Joe. Well explained. Thanks
Reply
16. amit said on 14/09/2011,
great post
Reply
17. Rajesh said on 28/09/2011,
Nice article
Reply
18. Elakkiya said on 29/09/2011,
Such a nice article i have ever seen..
Reply
19. Anant Choubey said on 08/10/2011,
http://javapapers.com/core-java/java-hashtable/#comment-7750http://javapapers.com/core-java/java-hashtable/?replytocom=7631#respondhttp://javapapers.com/core-java/java-hashtable/#comment-7631http://javapapers.com/core-java/java-hashtable/?replytocom=7622#respondhttp://javapapers.com/core-java/java-hashtable/#comment-7622http://javapapers.com/core-java/java-hashtable/?replytocom=7459#respondhttp://javapapers.com/core-java/java-hashtable/#comment-7459http://javapapers.com/core-java/java-hashtable/?replytocom=7391#respondhttp://javapapers.com/core-java/java-hashtable/#comment-7391http://javapapers.com/core-java/java-hashtable/?replytocom=7281#respondhttp://javapapers.com/core-java/java-hashtable/#comment-7281http://javapapers.com/http://javapapers.com/core-java/java-hashtable/?replytocom=7279#respondhttp://javapapers.com/core-java/java-hashtable/#comment-7279http://javapapers.com/core-java/java-hashtable/?replytocom=7268#respondhttp://javapapers.com/core-java/java-hashtable/#comment-7268http://javapapers.com/core-java/java-hashtable/?replytocom=7265#respondhttp://javapapers.com/core-java/java-hashtable/#comment-72657/30/2019 Java Hashtable
8/20
5/15/13 Java Hashtable
javapapers.com/core-java/java-hashtable/ 8
Worth Reading. Nice post. Looking forward for more :) keep posting
Reply
20. Partha said on 10/10/2011,
Instead of using HashTable, If we use HashMap and put those block in a synchronized block..what you
say on performance?
Reply21. Joe said on 10/10/2011,
@Partha, using HashMap enclosed in a synchronized block is costlier than using a Hashtable. Since, the
synchronization in Hashtable is fine-grained than this approach.
The best possible approach would be analyze the need for synchronization and avoid using Hashtable.
Reply
Ashok said on 17/02/2013,
Dear Joe,
Please explain how this hashCode() returns hash number and why attributes i and j are converted
into String
int i,j;
public int hashCode()
{
String s1 += Integer.toString(i);
String s2 += Integer.toString(j);
return hash;}
Reply
22. satesh said on 14/10/2011,
Very good explanation.Thanks alot :-)
Reply
23. ROCKS said on 15/10/2011,
Very Nice.. Keep it mate!!
Reply
24. Anonymous said on 24/10/2011,
awesome CSS !! i like it very much :D contents are lucid and to the point.. :)
Reply
25. Aman Prakash Mohla said on 29/10/2011,
http://javapapers.com/core-java/java-hashtable/#comment-8013http://www.javaconcepts.in/http://javapapers.com/core-java/java-hashtable/?replytocom=7970#respondhttp://javapapers.com/core-java/java-hashtable/#comment-7970http://javapapers.com/core-java/java-hashtable/?replytocom=7844#respondhttp://javapapers.com/core-java/java-hashtable/#comment-7844http://javapapers.com/core-java/java-hashtable/?replytocom=7828#respondhttp://javapapers.com/core-java/java-hashtable/#comment-7828http://javapapers.com/core-java/java-hashtable/?replytocom=23595#respondhttp://javapapers.com/core-java/java-hashtable/#comment-23595http://javapapers.com/core-java/java-hashtable/?replytocom=7776#respondhttp://javapapers.com/core-java/java-hashtable/#comment-7776http://javapapers.com/http://javapapers.com/core-java/java-hashtable/?replytocom=7774#respondhttp://javapapers.com/core-java/java-hashtable/#comment-7774http://javapapers.com/core-java/java-hashtable/?replytocom=7750#respond7/30/2019 Java Hashtable
9/20
5/15/13 Java Hashtable
javapapers.com/core-java/java-hashtable/ 9
Really nice post, comprehensive and upto the mark. I have also covered some important aspects of the
Java Map interface on myblog . You would also find a detailed post on Map synchronization and
concurrent HashMaps.
Reply
26. prabha said on 04/11/2011,
It is very simple language that you used in this blog which makes me very impressive to read a lot of stuff
about java from this blog. I am fortunate to take look at this website. Hopefully you will be coming up with
better and essential information regarding Java.
Thank you so much
from
Prabha
Reply
neeraj said on 30/04/2013,
ok
Reply
27. Grasshopper Networksaid on 07/11/2011,
This is a lucid and nice Article. You can always keep adding the features and extra information. We are
also java developers and provide various projects for free. Would you give us an opportunity for a Guest
Posting to write about Image Processing in Java? We will wait for your positive response.
Reply
28. mangesh said on 15/11/2011,
Nice post.please try to elaborate it with some examples.
Reply
29. haripriya said on 16/11/2011,
very nice site and helpful for beginners :)
Reply
30. CAL said on 17/11/2011,
Hey joe the explanation is really excellent you can also post on struts, spring, hibernate.
Reply
31. muthu said on 22/11/2011,
Joe, Could you explain the Collision resolution for below scenario
Map map = new HashMap();
I- two keys are same .But it does not throw any exception. How it finds collision resolution?
http://javapapers.com/core-java/java-hashtable/#comment-8304http://javapapers.com/core-java/java-hashtable/?replytocom=8212#respondhttp://javapapers.com/core-java/java-hashtable/#comment-8212http://javapapers.com/core-java/java-hashtable/?replytocom=8200#respondhttp://javapapers.com/core-java/java-hashtable/#comment-8200http://javapapers.com/core-java/java-hashtable/?replytocom=8189#respondhttp://javapapers.com/core-java/java-hashtable/#comment-8189http://javapapers.com/core-java/java-hashtable/?replytocom=8091#respondhttp://javapapers.com/core-java/java-hashtable/#comment-8091http://grasshoppernetwork.com/http://javapapers.com/core-java/java-hashtable/?replytocom=30283#respondhttp://javapapers.com/core-java/java-hashtable/#comment-30283http://javapapers.com/core-java/java-hashtable/?replytocom=8066#respondhttp://javapapers.com/core-java/java-hashtable/#comment-8066http://javapapers.com/core-java/java-hashtable/?replytocom=8013#respondhttp://www.%20javaconcepts.in/category/articleseries/java-map/7/30/2019 Java Hashtable
10/20
5/15/13 Java Hashtable
javapapers.com/core-java/java-hashtable/ 10
map.put(abc,12);
map.put(abc,13);
&
II- two keys are different .But hascode values are same for two keys. How it finds collision resolution?
map.put(abc,15);
map.put(cba,18);
Reply
32. JRZ said on 27/11/2011,
Your point to this line when discussing the use of value.hashCode():
h += e.key.hashCode() ^ e.value.hashCode();
A line much like this exists (Hashtable.java:948 in jdk 6u23). However, this line is NOT used in the
regular business of put() and get(). Rather, it is the hashCode Entry inner class, which must overridehashCode() because it overrides equals().
In normal put() and get() operations, the values hashCode is never used. (This must be the case, because
the value is not known in a get operation.) Look at the get() method on line 332 and note that it only calls
key.hashCode().
Thanks for posting this article! Since its getting plenty of readership, I wanted to make sure that people
dont get the wrong idea and think that the values hashCode plays a role in the put operation.
Reply33. Mariusz Lotko said on 28/11/2011,
To be honest, calculating hash using both key.hashCode() and value.hashCode() is done in
Map.Entry.hashCode().
Hashtable uses _only_ the value of key.hashCode() to find value. It would be quite surprising to use
values hash for lookups.
I assume Map.Entry.hashCode() is implemented only for purpose of using Map.Entry as a key:
Map
Which maps par (String, Integer) -> Integer.
Reply
34. Anurag Bansal said on 03/12/2011,
Great post Buddy.
Keep posting :)
http://javapapers.com/core-java/java-hashtable/#comment-8499http://javapapers.com/core-java/java-hashtable/?replytocom=8399#respondhttp://javapapers.com/core-java/java-hashtable/#comment-8399http://javapapers.com/core-java/java-hashtable/?replytocom=8391#respondhttp://javapapers.com/core-java/java-hashtable/#comment-8391http://javapapers.com/core-java/java-hashtable/?replytocom=8304#respond7/30/2019 Java Hashtable
11/20
5/15/13 Java Hashtable
javapapers.com/core-java/java-hashtable/ 1
Reply
35. Rajasekar said on 06/12/2011,
Very nice..
Reply
36. Ramesh said on 13/12/2011,
nice explanation! i was struggling to understand about hash table and hash map.Now i am clear.Thanks alot.looking for more stuff.
Reply
37. Thangavel said on 18/12/2011,
Hi Joe,
Its pretty good article for Hashtable. I have got more idea about on this. The Explanation is very nice..
Keep on posting more article, best of luck.
Thangavel L Nathan.
Reply
38. Maganti Suryanarayana Murthy said on 22/12/2011,
Nice Article joe !But if you go into still deeper with articles it will be really great !
Reply
39. Vishnu said on 29/12/2011,
Good work dude. very very easy to understand
Reply
40. Ghanshyam said on 29/12/2011,
Please give a same demo for HashMap also.
Reply
41. chandran said on 04/01/2012,
Really very happy to see this articleThanks a lot
Reply
42. pavan said on 08/01/2012,
Information is very clear and in simple terminology. Thanks a lot.
Reply
43. anonimous said on 10/01/2012,
http://javapapers.com/core-java/java-hashtable/#comment-9207http://javapapers.com/core-java/java-hashtable/?replytocom=9143#respondhttp://javapapers.com/core-java/java-hashtable/#comment-9143http://javapapers.com/core-java/java-hashtable/?replytocom=9022#respondhttp://javapapers.com/core-java/java-hashtable/#comment-9022http://javapapers.com/core-java/java-hashtable/?replytocom=8900#respondhttp://javapapers.com/core-java/java-hashtable/#comment-8900http://javapapers.com/core-java/java-hashtable/?replytocom=8894#respondhttp://javapapers.com/core-java/java-hashtable/#comment-8894http://javapapers.com/core-java/java-hashtable/?replytocom=8755#respondhttp://javapapers.com/core-java/java-hashtable/#comment-8755http://www.bizedgeasia.com/http://javapapers.com/core-java/java-hashtable/?replytocom=8701#respondhttp://javapapers.com/core-java/java-hashtable/#comment-8701http://javapapers.com/core-java/java-hashtable/?replytocom=8645#respondhttp://javapapers.com/core-java/java-hashtable/#comment-8645http://javapapers.com/core-java/java-hashtable/?replytocom=8520#respondhttp://javapapers.com/core-java/java-hashtable/#comment-8520http://javapapers.com/core-java/java-hashtable/?replytocom=8499#respond7/30/2019 Java Hashtable
12/20
5/15/13 Java Hashtable
javapapers.com/core-java/java-hashtable/ 12
ok.thanks da keep posting
Reply
44. chandra said on 18/01/2012,
this blog is great but if u posting the examples with real time that would be better
Reply
45. shrinath said on 23/01/2012,
nice keep it up
Reply
46. Manjunath said on 08/02/2012,
why null is not allowed in Hastable..??
Reply
47. GeekDude said on 16/02/2012,
i think it should be edit.have a look on this code .,, java.util.Hashtable
Reply
48. Arvind Singh said on 21/02/2012,
Very nice discussionit has almost full coverage of the topic,which is most feared one in java..if you
please give some practical examples..then it will increase readers understanding
Reply
49. Raajesh said on 13/03/2012,
Hi Joe,
Worth going through this article well done
Regards
Raajesh
Reply
50. dimuthu said on 25/03/2012,
This is great!
Reply
51. ahmed farag said on 26/05/2012,
i want hashcode for long string without collision please.
Reply
http://javapapers.com/core-java/java-hashtable/?replytocom=12235#respondhttp://javapapers.com/core-java/java-hashtable/#comment-12235http://javapapers.com/core-java/java-hashtable/?replytocom=10808#respondhttp://javapapers.com/core-java/java-hashtable/#comment-10808http://javapapers.com/core-java/java-hashtable/?replytocom=10564#respondhttp://javapapers.com/core-java/java-hashtable/#comment-10564http://javapapers.com/core-java/java-hashtable/?replytocom=10161#respondhttp://javapapers.com/core-java/java-hashtable/#comment-10161http://javapapers.com/core-java/java-hashtable/?replytocom=10042#respondhttp://javapapers.com/core-java/java-hashtable/#comment-10042http://javapapers.com/core-java/java-hashtable/?replytocom=9843#respondhttp://javapapers.com/core-java/java-hashtable/#comment-9843http://javapapers.com/core-java/java-hashtable/?replytocom=9501#respondhttp://javapapers.com/core-java/java-hashtable/#comment-9501http://javapapers.com/core-java/java-hashtable/?replytocom=9387#respondhttp://javapapers.com/core-java/java-hashtable/#comment-9387http://javapapers.com/core-java/java-hashtable/?replytocom=9207#respond7/30/2019 Java Hashtable
13/20
5/15/13 Java Hashtable
javapapers.com/core-java/java-hashtable/ 13
52. mr.hello said on 12/06/2012,
excellent and super
Reply
53. BLOB said on 23/06/2012,
You are awesome Last thing I am gonna say (Actually the first thing too)..
Reply
54. sweta said on 20/07/2012,
Thanks Joe for making Hashtable simple for me.All my queries are resolved after reading this short and
simple article.You rock :)
Reply
55. Anonymous said on 23/07/2012,
your explanation was good..also pl try to put simple example to construct a hashtable program in java..
by
Reader
Reply
56. Anonymous said on 28/07/2012,
Nice explanation, Ive one question. Plz give two different Keys which produces a same hashcode?
Reply
57. Bhushan said on 03/08/2012,
Please Post article on HashMap vs Hashtable
Reply
58. Anonymous said on 21/08/2012,
Sir,
Please write an article on Thread and Comparable/comparator. I like the the way you are explaining everytopic. This blog became as one of good references.
Reply
59. Muthuraj said on 27/08/2012,
Interesting.please write Hashtable vs Hashmap also. it will really help us
Reply
60. convex.naresh said on 30/08/2012,
http://javapapers.com/core-java/java-hashtable/#comment-15260http://javapapers.com/core-java/java-hashtable/?replytocom=15101#respondhttp://javapapers.com/core-java/java-hashtable/#comment-15101http://javapapers.com/core-java/java-hashtable/?replytocom=14850#respondhttp://javapapers.com/core-java/java-hashtable/#comment-14850http://javapapers.com/core-java/java-hashtable/?replytocom=14267#respondhttp://javapapers.com/core-java/java-hashtable/#comment-14267http://javapapers.com/core-java/java-hashtable/?replytocom=14084#respondhttp://javapapers.com/core-java/java-hashtable/#comment-14084http://javapapers.com/core-java/java-hashtable/?replytocom=13899#respondhttp://javapapers.com/core-java/java-hashtable/#comment-13899http://javapapers.com/core-java/java-hashtable/?replytocom=13852#respondhttp://javapapers.com/core-java/java-hashtable/#comment-13852http://javapapers.com/core-java/java-hashtable/?replytocom=13055#respondhttp://javapapers.com/core-java/java-hashtable/#comment-13055http://javapapers.com/core-java/java-hashtable/?replytocom=12743#respondhttp://javapapers.com/core-java/java-hashtable/#comment-127437/30/2019 Java Hashtable
14/20
5/15/13 Java Hashtable
javapapers.com/core-java/java-hashtable/ 14
Thank you for this post. Very useful article for me.
Reply
61. Swati said on 05/09/2012,
Thanks Joe,
can you please provide a full article on java collection framework with example.
Reply62. Anonymous said on 13/09/2012,
http://javapapers.com/wp-content/themes/papers/images/pencil.png
Reply
63. Anonymous said on 17/09/2012,
awesum
thanks for the details.
Reply
64. Bhanu Tekula said on 17/09/2012,
nice article..
Reply
65. Pankaj said on 23/09/2012,
Very good article Joe!
Reply
66. azer said on 26/09/2012,
very awesum. article joe
Reply
67. Anonymous said on 26/09/2012,
wow nice jun jun
Reply68. victor said on 26/09/2012,
wow nice jun jun
Reply
69. Ekanth said on 05/10/2012,
well expland dude.
http://javapapers.com/core-java/java-hashtable/#comment-16915http://javapapers.com/core-java/java-hashtable/?replytocom=16487#respondhttp://javapapers.com/core-java/java-hashtable/#comment-16487http://javapapers.com/core-java/java-hashtable/?replytocom=16486#respondhttp://javapapers.com/core-java/java-hashtable/#comment-16486http://javapapers.com/core-java/java-hashtable/?replytocom=16485#respondhttp://javapapers.com/core-java/java-hashtable/#comment-16485http://javapapers.com/core-java/java-hashtable/?replytocom=16320#respondhttp://javapapers.com/core-java/java-hashtable/#comment-16320http://javapapers.com/core-java/java-hashtable/?replytocom=16046#respondhttp://javapapers.com/core-java/java-hashtable/#comment-16046http://javapapers.com/core-java/java-hashtable/?replytocom=16031#respondhttp://javapapers.com/core-java/java-hashtable/#comment-16031http://javapapers.com/core-java/java-hashtable/?replytocom=15840#respondhttp://javapapers.com/wp-content/themes/papers/images/pencil.pnghttp://javapapers.com/core-java/java-hashtable/#comment-15840http://javapapers.com/core-java/java-hashtable/?replytocom=15501#respondhttp://javapapers.com/core-java/java-hashtable/#comment-15501http://javapapers.com/core-java/java-hashtable/?replytocom=15260#respond7/30/2019 Java Hashtable
15/20
5/15/13 Java Hashtable
javapapers.com/core-java/java-hashtable/ 15
Reply
70. Anonymous said on 09/10/2012,
first time i understood the hashcode and equalsmethod in java good work it helps lot of people
Reply
71. Ramesh said on 09/10/2012,
Great post Joe :) Keep posting more..
Reply
72. gopal said on 11/10/2012,
gr8
Reply
73. ankit said on 15/10/2012,
its really very gud articlebut it cover only 1 topic..should post more article.
Reply
74. Pankaj said on 29/10/2012,
yeah site is very useful for beginner as well as for those who want to know about any specific topic.
great! Thank you very much
Reply
75. Neeraj said on 31/10/2012,
Also put all Hashing Techniques like Bucket all that.
Reply
76. Manish Kumar said on 06/11/2012,
very very clear explanation on hash table..
Thanks a lot
Reply
77. cc said on 07/11/2012,
wonderful
i love you!
Reply
78. Tamawy said on 15/11/2012,
Quick and briefly useful. Thank you for that. We need easy examples to start with and increase our skills
in hashing.
http://javapapers.com/core-java/java-hashtable/#comment-18934http://www.etaworx.com/http://javapapers.com/core-java/java-hashtable/?replytocom=18661#respondhttp://javapapers.com/core-java/java-hashtable/#comment-18661http://javapapers.com/core-java/java-hashtable/?replytocom=18611#respondhttp://javapapers.com/core-java/java-hashtable/#comment-18611http://javapapers.com/core-java/java-hashtable/?replytocom=18332#respondhttp://javapapers.com/core-java/java-hashtable/#comment-18332http://javapapers.com/core-java/java-hashtable/?replytocom=18164#respondhttp://javapapers.com/core-java/java-hashtable/#comment-18164http://javapapers.com/core-java/java-hashtable/?replytocom=17373#respondhttp://javapapers.com/core-java/java-hashtable/#comment-17373http://javapapers.com/core-java/java-hashtable/?replytocom=17202#respondhttp://javapapers.com/core-java/java-hashtable/#comment-17202http://javapapers.com/core-java/java-hashtable/?replytocom=17059#respondhttp://javapapers.com/core-java/java-hashtable/#comment-17059http://javapapers.com/core-java/java-hashtable/?replytocom=17056#respondhttp://javapapers.com/core-java/java-hashtable/#comment-17056http://javapapers.com/core-java/java-hashtable/?replytocom=16915#respond7/30/2019 Java Hashtable
16/20
5/15/13 Java Hashtable
javapapers.com/core-java/java-hashtable/ 16
Thank you
Reply
79. kamal sharma said on 30/11/2012,
Thank you very much.
very well explained !!!
Reply80. Anonymous said on 15/12/2012,
Very wonder full article.
I like very much
Reply
81. Srinu D said on 15/12/2012,
Very good article..
I like that.Thank you very much
Reply
82. neha said on 04/01/2013,
thank you.
Reply
83. venkat said on 07/01/2013,
Hi Joe,Can you please clarify my doubt about HashTable.
the locking will happen only for adding/removing the object or every operation (reading also )
Reply
84. Ganesh said on 08/01/2013,
Nice article Joe, helps understand the basics very well !
Reply
85. abhishek said on 08/01/2013,
Hi Joe,
It was nice article
Thanks
Reply
86. Narpath said on 16/01/2013,
http://javapapers.com/core-java/java-hashtable/#comment-21907http://javapapers.com/core-java/java-hashtable/?replytocom=21398#respondhttp://javapapers.com/core-java/java-hashtable/#comment-21398http://javapapers.com/core-java/java-hashtable/?replytocom=21394#respondhttp://javapapers.com/core-java/java-hashtable/#comment-21394http://javapapers.com/core-java/java-hashtable/?replytocom=21336#respondhttp://javapapers.com/core-java/java-hashtable/#comment-21336http://javapapers.com/core-java/java-hashtable/?replytocom=21181#respondhttp://javapapers.com/core-java/java-hashtable/#comment-21181http://javapapers.com/core-java/java-hashtable/?replytocom=20427#respondhttp://javapapers.com/core-java/java-hashtable/#comment-20427http://javapapers.com/core-java/java-hashtable/?replytocom=20425#respondhttp://javapapers.com/core-java/java-hashtable/#comment-20425http://javapapers.com/core-java/java-hashtable/?replytocom=19647#respondhttp://javapapers.com/core-java/java-hashtable/#comment-19647http://javapapers.com/core-java/java-hashtable/?replytocom=18934#respond7/30/2019 Java Hashtable
17/20
5/15/13 Java Hashtable
javapapers.com/core-java/java-hashtable/ 17
Hi joe,
Please provide How will we handle the error code like 500 internal server error in application level ?
Reply
87. Kushagra Thapar said on 24/01/2013,
Hey Joe!
It is a very nice article, it helped me a lot.But it would be very nice if you explain about how buckets are created and handled in hashtables.
Reply
88. Anonymous said on 30/01/2013,
It was nice article.
Thanks,
Subbu
Reply
89. Gangadhar siraveni said on 06/02/2013,
Hi Good Morning Sir,
I am getting confusion in ovberriding equals and hasshcode methods will please provide in detail
information
Reply
90. Ashok said on 17/02/2013,
Dear Joe,
Please explain how this hashCode() returns hash number and why attributes i and j are converted into
String
int i,j;
public int hashCode()
{
String s1 += Integer.toString(i);
String s2 += Integer.toString(j);
return hash;}
Reply
Sanjay said on 17/02/2013,
Dear Ashok i think u missing some codes how it will return hash whn u not defined
Reply
91. Joseph said on 26/02/2013,
http://javapapers.com/core-java/java-hashtable/#comment-24131http://javapapers.com/core-java/java-hashtable/?replytocom=23597#respondhttp://javapapers.com/core-java/java-hashtable/#comment-23597http://javapapers.com/core-java/java-hashtable/?replytocom=23596#respondhttp://javapapers.com/core-java/java-hashtable/#comment-23596http://javapapers.com/core-java/java-hashtable/?replytocom=23077#respondhttp://javapapers.com/core-java/java-hashtable/#comment-23077http://javapapers/http://javapapers.com/core-java/java-hashtable/?replytocom=22672#respondhttp://javapapers.com/core-java/java-hashtable/#comment-22672http://javapapers.com/core-java/java-hashtable/?replytocom=22331#respondhttp://javapapers.com/core-java/java-hashtable/#comment-22331http://javapapers.com/core-java/java-hashtable/?replytocom=21907#respond7/30/2019 Java Hashtable
18/20
5/15/13 Java Hashtable
javapapers.com/core-java/java-hashtable/ 18
Really fantastic article, thanks, Joe
Reply
92. Chitta said on 11/03/2013,
Beautiful article
Reply
93. kavitha said on 17/03/2013,
hi joe,
can you tell me the formula to calculate hash function?
Reply
94. vamsee said on 09/04/2013,
Hi Joe,
i have been following your Articles in your websiteThey are just awesome
Can u please come up with Struts explanation Saying what happens inside the ActionServlet and how
RequestProcessor Handles
Reply
95. r.emmanuel angelo said on 11/04/2013,
iam new to java can anyone explain why hash map is used for?
Reply96. pandu said on 22/04/2013,
good explaination
Reply
97. Rajkumar Chaudhary said on 26/04/2013,
Fantastic explanation,You are really Astute person.
Reply
98. Sowmya said on 06/05/2013,
Very Good Explanation
Reply
Leave a Reply
Your email address will not be published.
http://javapapers.com/core-java/java-hashtable/?replytocom=30685#respondhttp://javapapers.com/core-java/java-hashtable/#comment-30685http://javapapers.com/core-java/java-hashtable/?replytocom=29977#respondhttp://javapapers.com/core-java/java-hashtable/#comment-29977http://javapapers.com/core-java/java-hashtable/?replytocom=29276#respondhttp://javapapers.com/core-java/java-hashtable/#comment-29276http://javapapers.com/core-java/java-hashtable/?replytocom=27571#respondhttp://javapapers.com/core-java/java-hashtable/#comment-27571http://javapapers.com/core-java/java-hashtable/?replytocom=27293#respondhttp://javapapers.com/core-java/java-hashtable/#comment-27293http://javapapers.com/core-java/java-hashtable/?replytocom=25071#respondhttp://javapapers.com/core-java/java-hashtable/#comment-25071http://javapapers.com/core-java/java-hashtable/?replytocom=24771#respondhttp://javapapers.com/core-java/java-hashtable/#comment-24771http://javapapers.com/core-java/java-hashtable/?replytocom=24131#respond7/30/2019 Java Hashtable
19/20
5/15/13 Java Hashtable
javapapers.com/core-java/java-hashtable/ 19
Name
Website
Comment
You may use these HTML tags and attributes:
Post Comment
ABOUT
I am Joe, author of this blog. I run javapapers with loads of passion. If you are into java, you may find lot of
interesting things around.Say hi:[email protected]+
Ads by Google
STAY in TOUCH:
Email: Subscribe
http://www.googleadservices.com/pagead/aclk?sa=L&ai=COS5sBD-TUdDiFOLIigetvIHICPvetK0Cq9PXgViT-_nekQEQASD4iPkFUM6Bk6v6_____wFg5crlg7QOoAHFx_HeA8gBAqkC6PwG_tmZUz6oAwHIA9EEqgSMAU_QlCBcjmQXzBnEU-xu7ePeyF3BxsCmovOqDoVkYZY_D8XyXMJ4mfXNj-b8WX_Ww0vcZSJoRYICGJHQKa8-Iwv_mdUPY_PAEpHHNfpUhiExnukeHvDwmemYrhoWV_08eVyTNXBOv-BQQJgTnLG25I8SDlzI6rlKzCPco92DnyatEXe3tsNg2udLuDBgiAYBoAYCgAejuI4h&num=1&cid=5GinRO5zI_pYwXJpsVUdwPiK&sig=AOD64_2hH6PDN8oVdkavh5bnYGD26zAOJA&client=ca-pub-2525233393528874&adurl=http://www.naaptol.com/top-brands/karbonn/mobile_handsets.html%3Fntpromoid%3D9203%26utm_source%3DGOOGLE%26utm_medium%3Dbanner%26utm_campaign%3DKarbonn-Mobile-Rmkt%26utm_code%3Dgoogle-bannerhttps://plus.google.com/101468817683594003129?rel=authormailto:[email protected]://javapapers.com/about-me/7/30/2019 Java Hashtable
20/20
5/15/13 Java Hashtable
CATEGORIES
Android
Core Java
ServletJSP
Design Patterns
Spring
All Tutorials
EVERGREEN
Association, Aggregation, Composition, Abstraction, Generalization, Realization, Dependency
Eclipse Shortcuts
Java Versions, Features and HistoryJava Serialization
Difference Between Interface and Abstract Class
Java Hashtable
Difference between forward and sendRedirect
Differentiate JVM JRE JDK JIT
Java (JVM) Memory Types
Why Multiple Inheritance is Not Supported in Java
Core Java | Servlet | JSP | Design Patterns | Android | Spring | Web Service | 2008-2012 javapapers.
Like 25 people like this.
http://javapapers.com/feed/http://twitter.com/javapapers/https://plus.google.com/101468817683594003129?rel=authorhttp://www.facebook.com/javapapershttp://javapapers.com/category/web-service/http://javapapers.com/category/spring/http://javapapers.com/category/android/http://javapapers.com/category/design-patterns/http://javapapers.com/category/jsp/http://javapapers.com/category/servlet/http://javapapers.com/category/core-java/http://javapapers.com/category/design-patterns/http://javapapers.com/category/jsp/http://javapapers.com/category/servlet/http://javapapers.com/category/core-java/http://javapapers.com/http://javapapers.com/core-java/why-multiple-inheritance-is-not-supported-in-java/http://javapapers.com/core-java/java-jvm-memory-types/http://javapapers.com/core-java/differentiate-jvm-jre-jdk-jit/http://javapapers.com/jsp/difference-between-forward-and-sendredirect/http://javapapers.com/core-java/java-hashtable/http://javapapers.com/core-java/abstract-and-interface-core-java-2/difference-between-a-java-interface-and-a-java-abstract-class/http://javapapers.com/core-java/java-serialization/http://javapapers.com/core-java/java-features-and-history/http://javapapers.com/core-java/eclipse-shortcuts/http://javapapers.com/oops/association-aggregation-composition-abstraction-generalization-realization-dependency/http://javapapers.com/site-map/http://javapapers.com/category/spring/http://javapapers.com/category/design-patterns/http://javapapers.com/category/jsp/http://javapapers.com/category/servlet/http://javapapers.com/category/core-java/http://javapapers.com/category/android/https://plus.google.com/101468817683594003129?rel=authorhttp://feeds.feedburner.com/javapapers/java-interview-questions