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

  • Thread starter Thread starter pairofstrings
  • Start date Start date
  • Tags Tags
    Concept Java
AI Thread Summary
The discussion centers around the relationship between hashing concepts and the Java Hashtable implementation. Key points include the distinction between hash functions, hash codes, and various collision handling techniques such as separate chaining and open addressing. It is highlighted that while understanding these concepts can enhance knowledge of how hashing works, they are not necessary for using Java's Hashtable or HashMap effectively. The hashcode() method in Java is essential for determining the appropriate bucket for storing objects, and while collisions can occur, the underlying implementation handles these scenarios. For most users, the Hashtable functions as a "black box," allowing for straightforward usage without needing in-depth knowledge of hashing mechanics, except when implementing custom classes as keys.
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.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...

Similar threads

Back
Top