List of usage examples for java.util Hashtable put
public synchronized V put(K key, V value)
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"); boolean blnExists = ht.contains("Two"); System.out.println("Two exists in Hashtable ? : " + blnExists); }
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"); System.out.println(table.isEmpty()); System.out.println(table.size()); }
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"); table.clear();//from w w w . j ava2s. c o m System.out.println(table); }
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"); table.remove("key1"); System.out.println(table);/*from ww w.jav a 2 s . com*/ }
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();/*from w w w . j a va 2 s .c o m*/ while (e.hasMoreElements()) System.out.println(e.nextElement()); e = h.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"); Hashtable tableCopy = (Hashtable) table.clone(); System.out.println(tableCopy); }
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()); }//from w w w. j a va2 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"); Enumeration e = ht.keys();//from w w w. j a va2 s . c om while (e.hasMoreElements()) { System.out.println(e.nextElement()); } }
From source file:MainClass.java
public static void main(String[] args) { String data;/*ww w .j ava 2s .c o m*/ 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:MainClass.java
public static void main(String args[]) throws Exception { Hashtable hash = new Hashtable(89); hash.put("one", "two"); hash.put("two", "three"); hash.put("three", "four"); hash.put("four", "five"); System.out.println(hash);// www .j av a 2 s . c om System.out.println(hash.size()); Enumeration e = hash.keys(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); System.out.println(key + " : " + hash.get(key)); } Set set = hash.entrySet(); Iterator it = set.iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); System.out.println(entry.getKey() + " : " + entry.getValue()); } }