List of usage examples for java.util Hashtable remove
public synchronized V remove(Object key)
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"); table.remove("key1"); System.out.println(table);/*from w w w . j a va 2 s . c o m*/ }
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 w ww. j a v a2 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"); Object obj = ht.remove("2"); System.out.println(obj + " was Removed "); Enumeration e = ht.elements(); while (e.hasMoreElements()) { System.out.println(e.nextElement()); }/* w w w . ja v a 2s .co m*/ }
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[]) { // 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("Initial hash table value: " + htable1); // remove element at key 3 htable1.remove(3); System.out.println("Hash table value after remove: " + htable1); }
From source file:ReflectClass.java
public static void main(String args[]) { Constructor cn[];//from w w w. j av a 2 s . co m Class cc[]; Method mm[]; Field ff[]; Class c = null; Class supClass; String x, y, s1, s2, s3; Hashtable classRef = new Hashtable(); if (args.length == 0) { System.out.println("Please specify a class name on the command line."); System.exit(1); } try { c = Class.forName(args[0]); } catch (ClassNotFoundException ee) { System.out.println("Couldn't find class '" + args[0] + "'"); System.exit(1); } /* * Step 0: If our name contains dots we're in a package so put * that out first. */ x = c.getName(); if (x.lastIndexOf(".") != -1) { y = x.substring(0, x.lastIndexOf(".")); System.out.println("package " + y + ";\n\r"); } /* * Let's use the Reflection API to sift through what is * inside this class. * * Step 1: Collect referenced classes * This step is used so that I can regenerate the import statements. * It isn't strictly required of course, Java works just fine with * fully qualified object class names, but it looks better when you * use 'String' rather than 'java.lang.String' as the return type. */ ff = c.getDeclaredFields(); for (int i = 0; i < ff.length; i++) { x = tName(ff[i].getType().getName(), classRef); } cn = c.getDeclaredConstructors(); for (int i = 0; i < cn.length; i++) { Class cx[] = cn[i].getParameterTypes(); if (cx.length > 0) { for (int j = 0; j < cx.length; j++) { x = tName(cx[j].getName(), classRef); } } } mm = c.getDeclaredMethods(); for (int i = 0; i < mm.length; i++) { x = tName(mm[i].getReturnType().getName(), classRef); Class cx[] = mm[i].getParameterTypes(); if (cx.length > 0) { for (int j = 0; j < cx.length; j++) { x = tName(cx[j].getName(), classRef); } } } // Don't import ourselves ... classRef.remove(c.getName()); /* * Step 2: Start class description generation, start by printing * out the import statements. * * This is the line that goes 'public SomeClass extends Foo {' */ for (Enumeration e = classRef.keys(); e.hasMoreElements();) { System.out.println("import " + e.nextElement() + ";"); } System.out.println(); /* * Step 3: Print the class or interface introducer. We use * a convienience method in Modifer to print the whole string. */ int mod = c.getModifiers(); System.out.print(Modifier.toString(mod)); if (Modifier.isInterface(mod)) { System.out.print(" interface "); } else { System.out.print(" class "); } System.out.print(tName(c.getName(), null)); supClass = c.getSuperclass(); if (supClass != null) { System.out.print(" extends " + tName(supClass.getName(), classRef)); } System.out.println(" {"); /* * Step 4: Print out the fields (internal class members) that are declared * by this class. * * Fields are of the form [Modifiers] [Type] [Name] ; */ System.out.println("\n\r/*\n\r * Field Definitions.\r\n */"); for (int i = 0; i < ff.length; i++) { Class ctmp = ff[i].getType(); int md = ff[i].getModifiers(); System.out.println(" " + Modifier.toString(md) + " " + tName(ff[i].getType().getName(), null) + " " + ff[i].getName() + ";"); } /* * Step 5: Print out the constructor declarations. * * We note the name of the class which is the 'name' for all * constructors. Also there is no type, so the definition is * simplye [Modifiers] ClassName ( [ Parameters ] ) { } * */ System.out.println("\n\r/*\n\r * Declared Constructors. \n\r */"); x = tName(c.getName(), null); for (int i = 0; i < cn.length; i++) { int md = cn[i].getModifiers(); System.out.print(" " + Modifier.toString(md) + " " + x); Class cx[] = cn[i].getParameterTypes(); System.out.print("( "); if (cx.length > 0) { for (int j = 0; j < cx.length; j++) { System.out.print(tName(cx[j].getName(), null)); if (j < (cx.length - 1)) System.out.print(", "); } } System.out.print(") "); System.out.println("{ ... }"); } /* * Step 6: Print out the method declarations. * * Now methods have a name, a return type, and an optional * set of parameters so they are : * [modifiers] [type] [name] ( [optional parameters] ) { } */ System.out.println("\n\r/*\n\r * Declared Methods.\n\r */"); for (int i = 0; i < mm.length; i++) { int md = mm[i].getModifiers(); System.out.print(" " + Modifier.toString(md) + " " + tName(mm[i].getReturnType().getName(), null) + " " + mm[i].getName()); Class cx[] = mm[i].getParameterTypes(); System.out.print("( "); if (cx.length > 0) { for (int j = 0; j < cx.length; j++) { System.out.print(tName(cx[j].getName(), classRef)); if (j < (cx.length - 1)) System.out.print(", "); } } System.out.print(") "); System.out.println("{ ... }"); } /* * Step 7: Print out the closing brace and we're done! */ System.out.println("}"); }
From source file:com.projity.configuration.Dictionary.java
public static void remove(NamedItem namedItem) { String categories[] = namedItem.getCategory().split(";"); // can belong to more than one if separated by ; for (int i = 0; i < categories.length; i++) { String category = categories[i]; Hashtable subMap = (Hashtable) getInstance().mainMap.get(category); subMap.remove(namedItem.getName()); }//from w ww. ja v a 2 s. c o m }
From source file:Utilities.java
/** * Maps the specified key to the specified value in the specified * <code>Hashtable</code>. If the specified value is <code>null</code> any * existing mapping of the specified key is removed from the * <code>Hashtable</code>. The old value mapped to the specified key * is returned, or <code>null</code> if no value was mapped to the key. *//*from w w w .j av a 2 s . co m*/ public static Object put(Hashtable table, Object key, Object value) { return value == null ? table.remove(key) : table.put(key, value); }
From source file:fr.paris.lutece.plugins.search.solr.web.SolrSearchApp.java
private static void isSwitched(String strFacetQuery, Hashtable<String, Boolean> tabType) { if (strFacetQuery != null && tabType != null && tabType.containsKey(strFacetQuery) && tabType.get(strFacetQuery) == Boolean.FALSE) { tabType.remove(strFacetQuery); tabType.put(strFacetQuery, Boolean.TRUE); }/* ww w . j ava 2s. c o m*/ }
From source file:gdt.data.grain.Support.java
/** * Remove the key and the associated value from the * hash table. /*from w w w . j a va 2 s . com*/ * @param keyName key string * @param tab hash table. */ public static void removeKey(String keyName, Hashtable<String, ?> tab) { if (keyName == null) return; if (tab == null) return; Enumeration<String> en = tab.keys(); String curKey = null; while (en.hasMoreElements()) { curKey = (String) en.nextElement(); if (keyName.compareTo(curKey) == 0) { tab.remove(curKey); break; } } }