Tuesday, 3 March 2015

Java : Collection Framework : Hashtable (Put)


Click here to watch in Youtube : 
https://www.youtube.com/watch?v=n82DItya1AM&list=UUhwKlOVR041tngjerWxVccw

HashtableExample.java
import java.util.Hashtable;

/*
 * Example of put(K key,V value) method.
 */
public class HashtableExample
{
    public static void main(String[] args)
    {

        Hashtable<String, String> hashtable = new Hashtable<String, String>();

        System.out.println("hashtable : " + hashtable + "\n");

        /*
         * Key = CountryCode,Value = CountryName.
         * 
         * Maps the specified key to the specified value in this hashtable.
         * 
         * Neither the key nor the value can be null. The value can be retrieved
         * by calling the get method with a key that is equal to the original
         * key.
         */
        hashtable.put("AF", "AFGHANISTAN");
        hashtable.put("BE", "BELGIUM");
        hashtable.put("US", "UNITED STATES");

        System.out.println("hashtable : " + hashtable);

    }
}
Output
hashtable : {}

hashtable : {AF=AFGHANISTAN, BE=BELGIUM, US=UNITED STATES}
To Download HashtableDemoPut Project Click the below link
https://sites.google.com/site/javaee4321/java-collections/HashtableDemoPut.zip?attredirects=0&d=1

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • No comments:

    Post a Comment

    Google+ Followers

    Google+ Badge