Wednesday, October 16, 2013

Hashtable imp methods

Hashtable:


- It doesn't allow null keys and null values. But it already has one null key and one null value in it , And we are no more able to insert null keys and null values.

-It is Synchronized object.

- Since it extends Dictionary, There are two important metthods
abstract  Enumeration<V>elements()
          Returns an enumeration of the values in this dictionary.
abstract  Enumeration<K>keys()
          Returns an enumeration of the keys in this dictionary.

So HashTable has to implement there methods...
These two methods are not there in HashMap class because it implements Map interface and extends AbstractAMap class so no more methods it has to implement.

- Since it implements  Map interface, There are three important methods
 Set<Map.Entry<K,V>>entrySet()
          Returns a Set view of the mappings contained in this map.
 Set<K>keySet()
          Returns a Set view of the keys contained in this map.
 Collection<V>values()
          Returns a Collection view of the values contained in this map.

So, here you can do both iterate and enumerate keys as well as values.

- Since Hashtable implements Serializable, we can serialize this object. 
- Since Hashtable implements cloneable, we can get the shallow copy of the object.

HashMap imp methods


No comments:

Post a Comment