List of usage examples for java.util Hashtable Hashtable
public Hashtable()
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)); }/*from w w w .j a va 2 s . c om*/ System.out.println(table.values()); }
From source file:Main.java
public static void main(String args[]) { // create hash table Hashtable<Integer, String> htable1 = new Hashtable<Integer, String>(); // put values in table htable1.put(1, "A"); htable1.put(2, "B"); htable1.put(3, "C"); htable1.put(4, "from java2s.com"); System.out.println("Collection view of hash table: " + htable1.values()); }
From source file:Main.java
public static void main(String args[]) { // create hash table Hashtable<Integer, String> htable1 = new Hashtable<Integer, String>(); // put values in table htable1.put(1, "A"); htable1.put(2, "B"); htable1.put(3, "C"); htable1.put(4, "from java2s.com"); System.out.println("String form of hash table is: " + htable1.toString()); }
From source file:Main.java
public static void main(String args[]) { // create hash table Hashtable<Integer, String> htable1 = new Hashtable<Integer, String>(); // put values in table htable1.put(1, "A"); htable1.put(2, "B"); htable1.put(3, "C"); htable1.put(4, "from java2s.com"); System.out.println("Size of the hash table is: " + htable1.size()); }
From source file:Main.java
public static void main(String args[]) { Hashtable<String, String> hash = new Hashtable<String, String>(); hash.put("1", "one"); hash.put("2", "two"); hash.put("3", "three"); Enumeration keys = hash.keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); Object value = hash.get(key); System.out.println(key + " : " + value); }//www. j a va2 s. co m }
From source file:Main.java
public static void main(String args[]) { // create hash table Hashtable<Integer, String> htable1 = new Hashtable<Integer, String>(); // put values in table htable1.put(1, "A"); htable1.put(2, "B"); htable1.put(3, "C"); htable1.put(4, "from java2s.com"); // check if table is empty System.out.println("Is hash table empty :" + htable1.isEmpty()); }
From source file:Main.java
public static void main(String args[]) { // create hash table Hashtable<Integer, String> htable1 = new Hashtable<Integer, String>(); // put values in table htable1.put(1, "A"); htable1.put(2, "B"); htable1.put(3, "C"); htable1.put(4, "from java2s.com"); // get the hash code value System.out.println("Hash code value is :" + htable1.hashCode()); }
From source file:Main.java
public static void main(String args[]) { // create hash table Hashtable<Integer, String> htable1 = new Hashtable<Integer, String>(); // put values in table htable1.put(1, "A"); htable1.put(2, "B"); htable1.put(3, "C"); htable1.put(4, "from java2s.com"); // get values at key 3 System.out.println("Values at key 3 is:" + htable1.get(3)); }
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()); }//from w ww . j a va 2s . com }
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"); Map m = Collections.unmodifiableMap(table); m.put("key3", "value3"); System.out.println(m);// ww w . j av a2 s. c o m }