VOOZH about

URL: https://www.geeksforgeeks.org/java/copyonwritearrayset-remove-method-in-java/

⇱ CopyOnWriteArraySet remove() method in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

CopyOnWriteArraySet remove() method in Java

Last Updated : 11 Jul, 2025
The remove() method of CopyOnWriteArraySet removes the specified element if it is present in the set. Syntax:
public boolean remove(Object o)
Parameters: The function accepts a mandatory parameter o which specifies the element to be removed from the set if present. Return Value: The function returns true if set contains the specified element. Below programs illustrate the above function: Program 1:
Output:
CopyOnWriteArraySet: [32, 67, 98, 100]
Set after removal of 100 is: [32, 67, 98]
Program 2:
Output:
CopyOnWriteArraySet: [gopal, geeks, technical]
'scripter' is not present
Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CopyOnWriteArraySet.html#remove-java.lang.Object-
Comment