Click here to watch in Youtube :
https://www.youtube.com/watch?v=kf4MBNIXYcM&list=UUhwKlOVR041tngjerWxVccw
LinkedHashSetExample.java
Output
https://www.youtube.com/watch?v=kf4MBNIXYcM&list=UUhwKlOVR041tngjerWxVccw
LinkedHashSetExample.java
import java.util.LinkedHashSet; /* * Example of add(E e) method. */ public class LinkedHashSetExample { public static void main( String[] args ) { LinkedHashSet<String> linkedHashSet = new LinkedHashSet<String>(); System.out.println("linkedHashSet: " + linkedHashSet + "\n"); /* * Adds the specified element to this set if it is not already present. * * If this set already contains the element, the call leaves the set * unchanged and returns false. */ boolean isAdded = linkedHashSet.add("Dave"); System.out.println("isAdded : " + isAdded); System.out.println("linkedHashSet: " + linkedHashSet + "\n"); isAdded = linkedHashSet.add("Dave"); System.out.println("isAdded : " + isAdded); System.out.println("linkedHashSet: " + linkedHashSet); } }
linkedHashSet: [] isAdded : true linkedHashSet: [Dave] isAdded : false linkedHashSet: [Dave]
https://sites.google.com/site/javaee4321/java-collections/LinkedHashSetDemoAdd.zip?attredirects=0&d=1
See also:
No comments:
Post a Comment