Setzen Sie das Element Java entfernen
// Java code to illustrate Set.remove() method
import java.util.*;
public class SetDemo {
public static void main(String args[])
{
// Creating an empty Set
Set<String> set = new HashSet<String>();
// Use add() method to add elements into the Set
set.add("Welcome");
set.add("To");
set.add("Geeks");
set.add("4");
set.add("Geeks");
// Displaying the Set
System.out.println("Set: " + set);
// Removing elements using remove() method
set.remove("Geeks");
set.remove("4");
set.remove("Welcome");
// Displaying the Set after removal
System.out.println("Set after removing elements: "
+ set);
}
}
Confused Cow