- Java.util - WeakHashMap
- Java.util - Vector
- Java.util - UUID
- Java.util - TreeSet
- Java.util - TreeMap
- Java.util - TimeZone
- Java.util - TimerTask
- Java.util - Timer
- Java.util - StringTokenizer
- Java.util - Stack
- Java.util - SimpleTimeZone
- Java.util - ServiceLoader
- Java.util - Scanner
- Java.util - ResourceBundle.Control
- Java.util - ResourceBundle
- Java.util - Random
- Java.util - PropertyResourceBundle
- Java.util - PropertyPermission
- Java.util - Properties
- Java.util - PriorityQueue
- Java.util - Observable
- Java.util - Locale
- Java.util - ListResourceBundle
- Java.util - LinkedList
- Java.util - LinkedHashSet
- Java.util - LinkedHashMap
- Java.util - IdentityHashMap
- Java.util - Hashtable
- Java.util - HashSet
- Java.util - HashMap
- Java.util - GregorianCalendar
- Java.util - Formatter
- Java.util - EnumSet
- Java.util - EnumMap
- Java.util - Dictionary
- Java.util - Date
- Java.util - Currency
- Java.util - Collections
- Java.util - Calendar
- Java.util - BitSet
- Java.util - Arrays
- Java.util - ArrayList
- Java.util - ArrayDeque
- Java.util - Home
Java.util Package Extras
- Java.util - Discussion
- Java.util - Useful Resources
- Java.util - Enumerations
- Java.util - Exceptions
- Java.util - Interfaces
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Java.util.Hashtable Class
Introduction
The java.util.Hashtable class implements a hashtable, which maps keys to values.Following are the important points about Hashtable −
In this any non-null object can be used as a key or as a value.
If many entries are to be made into a Hashtable, creating it with a sufficiently large capacity may allow the entries to be inserted more efficiently than letting it perform automatic rehashing as needed to grow the table.
Class declaration
Following is the declaration for java.util.Hashtable class −
pubpc class Hashtable<K,V> extends Dictionary<K,V> implements Map<K,V>, Cloneable, Seriapzable
Class constructors
Sr.No. | Constructor & Description |
---|---|
1 | Hashtable() This constructs a new, empty hashtable with a default initial capacity (11) and load factor (0.75). |
2 | Hashtable(int initialCapacity) This constructs a new, empty hashtable with the specified initial capacity and default load factor (0.75). |
3 | Hashtable(int initialCapacity, float loadFactor) This constructs a new, empty hashtable with the specified initial capacity and the specified load factor. |
4 | Hashtable(Map<? extends K,? extends V> t) This constructs a new hashtable with the same mappings as the given Map. |
Class methods
Sr.No. | Method & Description |
---|---|
1 | This method clears this hashtable so that it contains no keys. |
2 | This method creates a shallow copy of this hashtable. |
3 | This method tests if some key maps into the specified value in this hashtable. |
4 | This method tests if the specified object is a key in this hashtable. |
5 | This method returns true if this hashtable maps one or more keys to this value. |
6 | This method returns an enumeration of the values in this hashtable. |
7 | This method returns a Set view of the mappings contained in this map. |
8 | This method compares the specified Object with this Map for equapty, as per the definition in the Map interface. |
9 | This method returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. |
10 | This method returns the hash code value for this Map as per the definition in the Map interface. |
11 | This method tests if this hashtable maps no keys to values. |
12 | This method returns an enumeration of the keys in this hashtable. |
13 | This method returns a Set view of the keys contained in this map. |
14 | This method maps the specified key to the specified value in this hashtable. |
15 | This method copies all of the mappings from the specified map to this hashtable. |
16 | This method increases the capacity of and internally reorganizes this hashtable, in order to accommodate and access its entries more efficiently. |
17 | This method removes the key (and its corresponding value) from this hashtable. |
18 | This method returns the number of keys in this hashtable. |
19 | This method returns a string representation of this Hashtable object in the form of a set of entries, enclosed in braces and separated by the ASCII characters ", " (comma and space). |
20 | This method returns a Collection view of the values contained in this map. |
Methods inherited
This class inherits methods from the following classes −
java.util.Object