Answers for "remove in hashset"

1

HashSet remove(Object o) method in java

import java.util.HashSet;
public class HashSetRemoveObjectMethodExample
{
   public static void main(String[] args)
   {
      HashSet<String> hs = new HashSet<String>();
      hs.add("hello");
      hs.add("world");
      hs.add("java");
      System.out.println("HashSet before using remove(Object o) method: " + hs);
      // remove string "world" from HashSet
      boolean bool = hs.remove("world");
      System.out.println("Has string removed? " + bool);
      System.out.println("HashSet after using remove(Object o) method: " + hs);
   }
}
Posted by: Guest on October-28-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language