Welcome to the Ranch!
If you go to your JDK installation folder, there is a file called
src.zip. This contains the source code of most of the
Java API classes.
Sandeep Dharwar wrote: What do we mean by Hashing, how does it work internally [Simplified but complete Explanation] ?
Hash tables have a number of
buckets to store their data. This way the hash table doesn't need to go through the entire data set to find a value. Instead, the hash code of the key determines in which bucket the entry goes. When looking up the value for a key, the hash table will only look in the bucket for that key. Similarly, when setting the value for a key, the hash table will put the value in the bucket for that key. This is how hash tables in general work. HashMap and Hashtable are not different.
See
http://en.wikipedia.org/wiki/Hash_table for more information.
What is the difference between : HashMap, HashTable and HashList ?
I don't know HashList, but HashMap and Hashtable are almost identical. The main differences are:
- Hashtable is synchronized, HashMap is not.
- HashMap allows null keys and values, Hashtable does not.
- Hashtable extends java.util.Dictionary and therefore has extra methods, and also several methods that do the same thing.
What do we mean by Constant Time Complexity and why does different implementation of Hash gives constant time operation ?
See
http://en.wikipedia.org/wiki/Time_complexity.
In short, constant time complexity means that it the difference in time between retrieving the value of a key in a hash table with 10 entries and retrieving the value of a key in a hash table with 10,000,000 entries is virtually absent.
However, only ideal hash tables really have constant time complexity. In reality, multiple entries will be stored in the same bucket. That means that the bucket still must be searched, and this is usually a linear operation (meaning that if you get 100 times as many entries, the search will take 100 times as long). The worse the hash implementation, the more entries there will be in each bucket, and the longer lookups will take. An ideal hash table has only buckets of size 1.