ANY HELP WITH THIS DATA STRUCTURES USING JAVA QUESTION: There are 7 parts to thi
ID: 3721664 • Letter: A
Question
ANY HELP WITH THIS DATA STRUCTURES USING JAVA QUESTION:
There are 7 parts to this question, please answer all of them if possible, it will be really helpful to me....Thank you!!!
Q1) What is the difference between a hash table and a hash map? What do they have in common? What is a hashcode? When do you need to override this method? What other method should we override as well? What method(s) would you use to list the keys in a hash table? What method(s) would you used to list the values in a hash table?
Explanation / Answer
1.The both Hashtable and HashMap are data-structures which are based upon hashing and the implementation of Map interface.These store key/value pairs in a hash table. The major difference between these two data structures are, HashMap is not thread-safe but Hashtable is thread-safe,such that we can't use HashMap in multi-threaded applications of Java without any external synchronization.
2.These both are the data structures which are part of the Java collection. They both use the key-value pairs in hashtable in order to store the objects. They both share some common features, such that both of these implement java.util.Map interface and both work on the principle of hashing.
3. HashCode returns an integer after the comparison of two objects if are equal then returns an equal int for the both objects else a diiferent number always if the two objects are not same.
4.Hash Code is actually a method which is overriden always when the equals() method is overridden.
5.equals() methos is overridden.
6.keys()
7.elements()