Java Set.remove(Object o)

Syntax

Set.remove(Object o) has the following syntax.

boolean remove(Object o)

Example

In the following code shows how to use Set.remove(Object o) method.


import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
//w  w w .  j  a v a 2s .c  o  m
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));

    set.remove("A");

    System.out.println(set);
  }
}