import
java.util.*;
import
java.util.Map.Entry;
class
HashTableImplementation<K, V>
{
private
Hashtable<K, V> hashTable;
public
HashTableImplementation()
{
hashTable =
new
Hashtable<K, V>();
}
public
HashTableImplementation(Map<?
extends
K, ?
extends
V> hashTable1)
{
hashTable =
new
Hashtable<K, V>(hashTable1);
}
public
void
clear()
{
hashTable.clear();
}
public
Object clone()
{
return
hashTable.clone();
}
public
boolean
contains(Object obj)
{
return
hashTable.contains(obj);
}
public
boolean
containsValue(Object val)
{
return
hashTable.containsValue(val);
}
public
boolean
containsKey(Object key)
{
return
hashTable.containsKey(key);
}
public
Enumeration<V> elements()
{
return
hashTable.elements();
}
public
Set<Map.Entry<K, V>> entrySet()
{
return
hashTable.entrySet();
}
public
boolean
equals(Object obj)
{
return
hashTable.equals(obj);
}
public
V get(Object key)
{
return
hashTable.get(key);
}
public
int
hashCode()
{
return
hashTable.hashCode();
}
public
boolean
isEmpty()
{
return
hashTable.isEmpty();
}
public
Enumeration<K> keys()
{
return
hashTable.keys();
}
public
Set<K> keySet()
{
return
hashTable.keySet();
}
public
V put(K key, V val)
{
return
hashTable.put(key, val);
}
public
int
size()
{
return
hashTable.size();
}
public
String toString()
{
return
hashTable.toString();
}
public
V remove(Object key)
{
return
hashTable.remove(key);
}
public
Collection<V> values()
{
return
hashTable.values();
}
}
public
class
GFG{
public
static
void
main(String[] arg)
{
HashTableImplementation<String, Integer> hashTable =
new
HashTableImplementation<>();
hashTable.put(
"Nikhil"
,
390
);
hashTable.put(
"Akshay"
,
280
);
hashTable.put(
"Bina"
,
500
);
hashTable.put(
"Chintu"
,
450
);
System.out.println(
"The size of the hashTable: "
+ hashTable.size());
System.out.println(
"Entry Set of the hashTable: "
);
Set<Entry<String, Integer>> entrySet = hashTable.entrySet();
Iterator<Entry<String, Integer>> entry = entrySet.iterator();
while
(entry.hasNext())
{
System.out.println(entry.next() +
" "
);
}
System.out.println();
System.out.println(
"The keys of the HashTable: "
);
Set<String> keySet = hashTable.keySet();
Iterator<String> it = keySet.iterator();
while
(it.hasNext())
{
System.out.print(it.next() +
" "
);
}
System.out.println();
System.out.println(
"The values of the HashTable:"
);
Collection<Integer> values = hashTable.values();
Iterator<Integer> itr = values.iterator();
while
(itr.hasNext())
{
System.out.print(itr.next() +
" "
);
}
System.out.println();
System.out.println(
"The hashTable contains Nikhil: "
+ hashTable.containsKey(
"Nikhil"
));
hashTable.clear();
System.out.println(
"The size of the hashTable: "
+ hashTable.size());
}
}