This blog is all about to learn Core Java Interview Programs and Coding tricks to polish your Java Knowledge. If you like the content of this blog please share this with your friends.
Previously we have discussed about
What is HashMap in Java ?
What is HashMap in Java ?
Here we learn what is HashTable in java.But before starting this you must know What is Map Interface in Java ?
Class Hashtable<K,V>
All Implemented Interfaces:
Direct Known Subclasses:
Declaration of HashTable:
public class Hashtable<K,V>
extends Dictionary<K,V>
implements Map<K,V>, Cloneable, Serializable
HashTable is implementation class of Map Interface.HashTable belongs to java.util.* package.
HashTable class maps keys to values.This class does not allow null as key or as value,and if we try to put any null key or any null value it will throw NullPointerException at runtime.
An instance of Hashtable has two parameters that affect its performance: initial capacity and load factor.
The capacity is the number of buckets in the hash table, and the initial capacity is simply the capacity at the time the hash table is created.
The load factor is a measure of how full the hash table is allowed to get before its capacity is automatically increased.Generally, the default load factor (.75)
Hashtable implementation is synchronized.HashTable is an example of fail-fast.
This class is a member of the Java Collections Framework.
Constructor and Description :-
Hashtable()
Constructs a new, empty hashtable with a default initial capacity (11) and load factor (0.75).
Hashtable(int initialCapacity)
Constructs a new, empty hashtable with the specified initial capacity and default load factor (0.75).
Hashtable(int initialCapacity, float loadFactor)
Constructs a new, empty hashtable with the specified initial capacity and the specified load factor.
Hashtable(Map<? extends K,? extends V> t)
Constructs a new hashtable with the same mappings as the given Map.
Java I/O Tutorial
No comments:
Post a Comment