Set.remove(Object o) has the following syntax.
boolean remove(Object o)
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; /*from ww w .j ava2s . co 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); } }
The code above generates the following result.