![]() |
VOOZH | about |
public void forEach (Consumer<E> action)Parameters: This method takes a parameter action which represents the action to be performed for each element. Return Value: This method does not returns anything. Exceptions: This method throws NullPointerException if the specified action is null. Below program illustrates the forEach() function of CopyOnWriteArraySet class: Example 1:
CopyOnWriteArraySet: [2, 3, 4, 7, 8] Traversing this Set: 2 3 4 7 8
CopyOnWriteArraySet: [GeeksforGeeks, Geeks, Computer Science, Portal, Gfg] Traversing this Set: GeeksforGeeks Geeks Computer Science Portal Gfg