List of usage examples for java.util Hashtable elements
public synchronized Enumeration<V> elements()
From source file:MainClass.java
public static void main(String[] s) { Hashtable table = new Hashtable(); table.put("key1", "value1"); table.put("key2", "value2"); table.put("key3", "value3"); Enumeration e = table.elements(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); System.out.println(key + " : " + table.get(key)); }//from ww w . jav a 2s. c om System.out.println(table.values()); }
From source file:Main.java
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"); Enumeration e = ht.elements(); while (e.hasMoreElements()) { System.out.println(e.nextElement()); }// ww w . ja v a2 s . c o m }
From source file:Main.java
public static void main(String[] args) { HashMap<String, String> hMap = new HashMap<String, String>(); hMap.put("1", "One"); hMap.put("2", "Two"); hMap.put("3", "Three"); Hashtable<String, String> ht = new Hashtable<String, String>(); ht.put("1", "REPLACED !!"); ht.put("4", "Four"); Enumeration e = ht.elements(); while (e.hasMoreElements()) { System.out.println(e.nextElement()); }//from w w w.j av a 2 s.c o m ht.putAll(hMap); e = ht.elements(); while (e.hasMoreElements()) { System.out.println(e.nextElement()); } }
From source file:Main.java
public static void main(String[] s) { Hashtable<String, String> table = new Hashtable<String, String>(); table.put("key1", "value1"); table.put("key2", "value2"); table.put("key3", "value3"); Enumeration e = table.elements(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); System.out.println(key + " : " + table.get(key)); }// ww w. ja v a2s . co m System.out.println(table.values()); }
From source file:Main.java
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"); Object obj = ht.remove("2"); System.out.println(obj + " was Removed "); Enumeration e = ht.elements(); while (e.hasMoreElements()) { System.out.println(e.nextElement()); }/*www.j a v a 2 s. c om*/ }
From source file:Main.java
public static void main(String args[]) { Hashtable<Integer, String> htable = new Hashtable<Integer, String>(); // put values into the table htable.put(1, "A"); htable.put(2, "B"); htable.put(3, "C"); htable.put(4, "from java2s.com"); // create enumeration Enumeration<String> e = htable.elements(); System.out.println("Display result:"); // display search result while (e.hasMoreElements()) { System.out.println(e.nextElement()); }//from ww w .j av a 2 s . c o m }
From source file:Main.java
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();//from w ww. j a va 2s . co m 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()); } }
From source file:Main.java
public static void main(String[] args) { Hashtable h = new Hashtable(20); System.out.println(h.put("one", new Integer(1))); System.out.println(h.put("name", "A")); System.out.println(h.put("date", new Date())); System.out.println(h.put("one", new Integer(4))); Enumeration e = h.keys();// w w w .j a v a2s.co m while (e.hasMoreElements()) System.out.println(e.nextElement()); e = h.elements(); while (e.hasMoreElements()) System.out.println(e.nextElement()); }
From source file:MainClass.java
public static void main(String[] args) { String data;/*from www . j a v a2 s. c om*/ String msg; Hashtable h = new Hashtable(20); System.out.println(h.put("one", new Integer(1))); System.out.println(h.put("name", "A")); System.out.println(h.put("date", new Date())); System.out.println(h.put("one", new Integer(4))); Enumeration e = h.keys(); while (e.hasMoreElements()) System.out.println(e.nextElement()); e = h.elements(); while (e.hasMoreElements()) System.out.println(e.nextElement()); }
From source file:Main.java
/** * Add all elements from the map to the vector. * The map element is assumed to be an object or a {@link Vector}. * @param vec/*w ww . jav a 2 s . co m*/ * @param map */ public static void addAllWithNestableValues(final Vector vec, final Hashtable map) { for (Enumeration e = map.elements(); e.hasMoreElements();) { final Object next = e.nextElement(); if (next instanceof Vector) { // values might be nested in another vector : addAll(vec, (Vector) next); } else { // simple value just add it : vec.addElement(next); } } }