Set: equals(Object o) : Set « java.util « Java by API






Set: equals(Object o)

 

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

public class Main {

  public static void main(String[] a) {
    String elements[] = { "A", "B", "C", "D", "E" };
    Set<String> set = new HashSet<String>(Arrays.asList(elements));

    elements = new String[] { "A", "B", "C", "D" };
    Set<String> set2 = new HashSet<String>(Arrays.asList(elements));

    System.out.println(set.equals(set2));
  }
}

   
  








Related examples in the same category

1.Set: add(String e)
2.Set: addAll(Collection c)
3.Set: clear()
4.Set: clone()
5.Set: contains(Object o)
6.Set: containsAll(Collection c)
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)