Click here to watch in Youtube :
https://www.youtube.com/watch?v=f0LQuvqePsg&list=UUhwKlOVR041tngjerWxVccw
HashSetExample.java
Output
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"); } }
hashSet: [Rohit, Dave, Phil, Peter, Virat]
https://sites.google.com/site/javaee4321/java-collections/HashSetDemoConstructor.zip?attredirects=0&d=1
See also:
No comments:
Post a Comment