List of usage examples for java.util Hashtable size
public synchronized int size()
From source file:Main.java
public static void main(String[] args) { Hashtable<String, String> ht = new Hashtable<String, String>(); System.out.println("Size of Hashtable : " + ht.size()); ht.put("1", "One"); ht.put("2", "Two"); ht.put("3", "Three"); System.out.println(ht.size()); Object obj = ht.remove("2"); System.out.println(ht.size()); }
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"); ht.clear();/*from w w w .j av a2s. c om*/ System.out.println(ht.size()); }
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"); 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"); System.out.println(table.isEmpty()); System.out.println(table.size()); }
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);/*from w w w . j a va 2 s.co m*/ 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()); } }
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 Hashtable nullIfEmpty(Hashtable h) { return (h == null ? null : (h.size() == 0 ? null : h)); }
From source file:Main.java
public static boolean emptyHash(Hashtable hash) { boolean result = true; if ((hash != null) && (hash.size() > 0)) { result = false;//from w w w. j av a2 s .c o m } return result; }
From source file:Main.java
/** * Convert to array./*from ww w.ja v a 2s .c om*/ * * @param data the data * * @return the object[] */ private static Object[] convertToArray(Hashtable data) { Object[] result = new Object[data.size()]; for (int i = 0; i < data.size(); i++) { result[i] = data.get(i + ""); } return result; }
From source file:org.compass.core.jndi.NamingHelper.java
public static InitialContext getInitialContext(CompassSettings settings) throws NamingException { Hashtable hash = getJndiProperties(settings); try {/*from w w w .jav a2s . c om*/ return (hash.size() == 0) ? new InitialContext() : new InitialContext(hash); } catch (NamingException e) { log.error("Could not obtain initial context with settings [" + hash + "]", e); throw e; } }