remove in hashset java code example
Example: 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);
boolean bool = hs.remove("world");
System.out.println("Has string removed? " + bool);
System.out.println("HashSet after using remove(Object o) method: " + hs);
}
}