Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

set remove element java

// 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);
    }
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #set #remove #element #java
ADD COMMENT
Topic
Name
2+9 =