Set: addAll(Collection c) : Set « java.util « Java by API






Set: addAll(Collection c)

 
/*
 Output:

true
false

 * */

import java.util.HashSet;
import java.util.Set;

public class MainClass {
  public static void main(String args[]) {
    Set set = new HashSet();
    Set set2 = new HashSet();
    StringBuffer buff1 = new StringBuffer("Irish Setter");
    StringBuffer buff2 = new StringBuffer("Irish Setter");
    set.add(buff1);
    set2.add(buff2);
    System.out.println(set.addAll(set2));
    System.out.println(set.addAll(set));
  }
}
           
         
  








Related examples in the same category

1.Set: add(String e)
2.Set: clear()
3.Set: clone()
4.Set: contains(Object o)
5.Set: containsAll(Collection c)
6.Set: equals(Object o)
7.Set: isEmpty()
8.Set: iterator()
9.Set: remove(Object o)
10.Set: removeAll(Collection c)
11.Set: retainAll(Collection c)
12.Set: size()
13.Set: toArray()
14.Set: toArray(String[] a)