Monday, 15 December 2014

Java : Collection Framework : HashSet (Constructor)


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

HashSetExample.java
import java.util.HashSet;

/*
 * Example of HashSet() Constructor.
 */
public class HashSetExample
{
    public static void main( String[] args )
    {
        /*
         * Constructs a new, empty set; the backing HashMap instance has default
         * initial capacity (16) and load factor (0.75).
         */
        HashSet<String> hashSet = new HashSet<String>();

        hashSet.add("Dave");
        hashSet.add("Peter");
        hashSet.add("Phil");
        hashSet.add("Rohit");
        hashSet.add("Virat");

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

    }
}

Output
hashSet: [Rohit, Dave, Phil, Peter, Virat]

To Download HashSetDemoConstructor Project Click the below link
https://sites.google.com/site/javaee4321/java-collections/HashSetDemoConstructor.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