fork download
  1.  
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class Demo {
  8.  
  9. public static void main(String a[]){
  10.  
  11. LinkedHashSet<String> s1 = new LinkedHashSet<String>();
  12. s1.add("first");
  13. s1.add("second");
  14. s1.add("third");
  15. System.out.println(s1);
  16. HashSet<String> subSet = new HashSet<String>();
  17. subSet.add("s1");
  18. subSet.add("s2");
  19. s1.addAll(subSet);
  20. System.out.println("LinkedHashSet content after adding another collection:");
  21. System.out.println(s1);
  22. }
  23. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
[first, second, third]
LinkedHashSet content after adding another collection:
[first, second, third, s1, s2]