Get Collection of Values from Java Hashtable : HashTable Map « Collections Data Structure « Java






Get Collection of Values from Java Hashtable

     

import java.util.Collection;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;

public class Main {
  public static void main(String[] args) {
    Hashtable<String, String> ht = new Hashtable<String,String>();
    ht.put("1", "One");
    ht.put("2", "Two");
    ht.put("3", "Three");

    Collection c = ht.values();
    Iterator itr = c.iterator();
    while (itr.hasNext()){
      System.out.println(itr.next());
    }
    c.remove("One");

    Enumeration e = ht.elements();

    while (e.hasMoreElements()){
      System.out.println(e.nextElement());
    }
  }
}

   
    
    
    
    
  








Related examples in the same category

1.Check if a particular key exists in Java Hashtable
2.Check if a particular value exists in Java Hashtable
3.Get Set view of Keys from Java Hashtable
4.Get Size of Java Hashtable
5.Iterate through keys of Java Hashtable
6.Remove all values from Java Hashtable
7.Scan the content of a hashtable
8.Remove value from Java Hashtable
9.Sort keys in an Hashtable
10.Associates keys with valuesAssociates keys with values
11.Iterate through values of Java Hashtable
12.A simple Map implementationA simple Map implementation
13.Hash table with separate chaining
14.Hash table with linear probingHash table with linear probing
15.Hash table with double hashingHash table with double hashing
16.Working with Key-Value Pairs in a Hashtable
17.Demonstrate the Hashtable class, and an Enumeration
18.Demonstrate the HashMap class, and an IteratorDemonstrate the HashMap class, and an Iterator
19.Soft HashMap
20.MultiMap extends AbstractMap
21.Array Map extends AbstractMapArray Map extends AbstractMap
22.Demonstrating the WeakHashMapDemonstrating the WeakHashMap
23.Use treemapUse treemap
24.Sorting Elements in a TreeMapSorting Elements in a TreeMap
25.What you can do with a TreeMapWhat you can do with a TreeMap
26.A Map implemented with ArrayLists
27.Simple demonstration of HashMapSimple demonstration of HashMap
28.HashMap
29.Caching Hashtable
30.Hashtable that supports mostly-concurrent reading, but exclusive writing.
31.Lru Hashtable
32.Bucketized Hashtable
33.Custom hash table based on customized array