Friday 27 February 2015

Java : Collection Framework : Hashtable (default Constructor)


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

HashtableExample.java
import java.util.Hashtable;

/*
 * Example of default Hashtable() Constructor.
 */
public class HashtableExample
{
    public static void main(String[] args)
    {

        /*
         * Constructs a new, empty hashtable with a default initial capacity
         * (11) and load factor (0.75).
         */
        Hashtable<Integer, String> hashtable = new Hashtable<Integer, String>();

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

        hashtable.put(1, "Apple");
        hashtable.put(2, "Ball");
        hashtable.put(3, "Cat");

        System.out.println("hashtable : " + hashtable);
    }
}
Output
hashtable : {}

hashtable : {3=Cat, 2=Ball, 1=Apple}
To Download HashtableDemoDefaultCons Project Click the below link
https://sites.google.com/site/javaee4321/java-collections/HashtableDemoDefaultCons.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