LinkedBlockingDeque forEach() method in Java with Examples
The forEach() method of LinkedBlockingDeque performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.
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 LinkedBlockingDeque class:
Linked Blocking Deque: [11, 22, 33, 44, 55, 66, 77] Traversing this Deque: 11 22 33 44 55 66 77
Linked Blocking Deque: [GeeksforGeeks, Gfg, Geeks, Computer, Science, Portal] Traversing this deque: GeeksforGeeks Gfg Geeks Computer Science Portal
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.