Click here to watch in Youtube :
https://www.youtube.com/watch?v=QjZ4EMY6BbI&list=UUhwKlOVR041tngjerWxVccw
LinkedHashSetExample.java
Output
https://www.youtube.com/watch?v=QjZ4EMY6BbI&list=UUhwKlOVR041tngjerWxVccw
LinkedHashSetExample.java
import java.util.LinkedHashSet; /* * Example of clone() method. */ public class LinkedHashSetExample { public static void main( String[] args ) { LinkedHashSet<String> linkedHashSet = new LinkedHashSet<String>(); linkedHashSet.add("Dave"); linkedHashSet.add("Peter"); linkedHashSet.add("Phil"); linkedHashSet.add("Rohit"); linkedHashSet.add("Virat"); System.out.println("linkedHashSet: " + linkedHashSet + "\n"); /* * Returns a shallow copy of this LinkedHashSet instance: the elements * themselves are not cloned. */ LinkedHashSet<String> clonedLinkedHashSet = (LinkedHashSet<String>) linkedHashSet.clone(); System.out.println("clonedLinkedHashSet : " + clonedLinkedHashSet); } }
linkedHashSet: [Dave, Peter, Phil, Rohit, Virat] clonedLinkedHashSet : [Dave, Peter, Phil, Rohit, Virat]
https://sites.google.com/site/javaee4321/java-collections/LinkedHashSetDemoClone.zip?attredirects=0&d=1
See also:
No comments:
Post a Comment