Click here to watch in Youtube :
https://www.youtube.com/watch?v=sdy1xgAmCcU&list=UUhwKlOVR041tngjerWxVccw
HashtableExample.java
Output
https://www.youtube.com/watch?v=sdy1xgAmCcU&list=UUhwKlOVR041tngjerWxVccw
HashtableExample.java
import java.util.Hashtable; /* * Example of remove(Object key) method. */ public class HashtableExample { public static void main( String[] args ) { Hashtable<String, String> hashtable = new Hashtable<String, String>(); /* * Key = CountryCode,Value = CountryName */ hashtable.put("AF", "AFGHANISTAN"); hashtable.put("BE", "BELGIUM"); hashtable.put("US", "UNITED STATES"); hashtable.put("IN", "INDIA"); System.out.println("hashtable : " + hashtable + "\n"); /* * Removes the key (and its corresponding value) from this hashtable. * * This method does nothing if the key is not in the hashtable. */ String value = hashtable.remove("US"); System.out.println("value : " + value + "\n"); System.out.println("hashtable : " + hashtable + "\n"); } }
hashtable : {IN=INDIA, AF=AFGHANISTAN, BE=BELGIUM, US=UNITED STATES} value : UNITED STATES hashtable : {IN=INDIA, AF=AFGHANISTAN, BE=BELGIUM}
https://sites.google.com/site/javaee4321/java-collections/HashtableDemoRemove.zip?attredirects=0&d=1
See also:
No comments:
Post a Comment