How to remove specific element from Hashset.
How to remove specific element from Hashset.Code:
HashSetRemoveElement.java
package net.roseindia; import java.util.HashSet; public class HashSetRemoveElement { public static void main(String[] arg) { HashSet obHashSet = new HashSet(); obHashSet.add("Bharat"); obHashSet.add("Gyan"); obHashSet.add("Ankita"); obHashSet.add("vrishti"); System.out.println("Element before remove method : " + obHashSet); obHashSet.remove("vrishti"); System.out.println("Element after remove method : " + obHashSet); } } |
Element before remove method : [Gyan, Ankita, vrishti, Bharat] Element after remove method : [Gyan, Ankita, Bharat] |