Java HashSet remove() MethodThe remove() is a method of Java HashSet class which removes the specified element from this set if it is present. SyntaxFollowing is the declaration of remove() method: Parameter
ReturnsThe remove() method returns true if the set contained the specified element. ExceptionsNA Compatibility VersionJava 1.2 and above Example 1Test it NowOutput: HashSet: [Vijay, Ravi, Aman, Ajay] HashSet after removing elements: [Ravi, Aman, Ajay] Example 2Test it NowOutput: HashSet: [98, 67, 24, 45] HashSet after removing elements: [67, 45] Example 3Test it NowOutput: 103 Operating System Galvin Wiley 6 101 Let us C Yashwant Kanetkar BPB 8 102 Data Communications & Networking Forouzan Mc Graw Hill 4 Books after remove method: 103 Operating System Galvin Wiley 6 101 Let us C Yashwant Kanetkar BPB 8
Next TopicHashSet size() Method
|