Do we have a concept(?) called 'Hashfunction' in 'Hashtable' in Java?

  • Context: Java 
  • Thread starter Thread starter pairofstrings
  • Start date Start date
  • Tags Tags
    Concept Java
Click For Summary
SUMMARY

The discussion clarifies the relationship between 'Hashfunction' and 'Hashtable' in Java, emphasizing that while the hashcode() method is crucial for determining the storage bucket in a Hashtable, understanding advanced concepts like collision handling and hashing techniques is not necessary for basic usage. The Java Hashtable operates as a black box, allowing developers to utilize its functionality without delving into its internal mechanics. However, when implementing custom classes as keys, knowledge of the hashcode() method becomes essential to ensure proper functionality.

PREREQUISITES
  • Understanding of Java Collections Framework
  • Familiarity with the hashcode() method in Java
  • Basic knowledge of collision handling techniques
  • Awareness of how Java Hashtable operates
NEXT STEPS
  • Research Java Hashtable implementation details
  • Learn about collision handling techniques such as separate chaining and open addressing
  • Explore the significance of the hashcode() method in custom class implementations
  • Investigate performance optimization strategies for hash-based data structures
USEFUL FOR

Java developers, software engineers, and computer science students seeking to understand the inner workings of hash-based data structures and improve their proficiency with Java's Collections Framework.

pairofstrings
Messages
411
Reaction score
7
I know what Hashtable is. I have seen the methods that it contains and used these methods. I know the differences between the implementation classes. But I have not come across anything called 'Hashfunction' during the time when I was studying Collections framework. Is this 'Hashfuntion' has something to do with 'Hashtable'?
I saw some videos and the guys were talking about 'Hashcode'(I know little bit about this), 'Compression function', 'Collision handling' and 'Separate chaining', 'Open addressing' and 'Linear probing', 'Double hashing', and they also talk about the performance of hashing..and 'associative arrays'. I am wondering if these concepts have something to do with 'Hashing technique'. I only know that there is something called Hashing technique which helps in making the searches faster. And there are "buckets" in which objects are stored in Hashing technique.
If all of these concepts belongs to Hashtable in Java, is it important to know all of these concepts to create Hashtable?
Thanks for your time.
 
Last edited:
Technology news on Phys.org
The Java Object has a hashcode() method which does some kinda default calculation -- I think it produces the value printed for objects that don't implement toString(). When you stuff Objects into a hash table the hashcode() method is called to figure out what hash bucket to use. There is some probability that two objects will have the same code, so hash stores need to be able to rummage through each bucket in order to find the actual object, but the hash code gets you to the right bucket with (usually) one integer compare. All those other concepts are optimizations. You actually don't need to know nutthin bout hashing to use the Java HashMap classes, they just (usually) work...
 
All of these words you are using are important for implementing a hashtable. The point of something like Hashtable in java is it should be a black box. You don't need to know what's going on inside. You just need to know it works.

The only thing you might need to care about is when you implement hashcode(), like schip666 said.

http://www.javapractices.com/topic/TopicAction.do?Id=28

But this is only if you are using custom classes as keys I think.
 

Similar threads

  • · Replies 20 ·
Replies
20
Views
31K
Replies
3
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
86
Views
3K
  • · Replies 19 ·
Replies
19
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K