VOOZH about

URL: https://www.geeksforgeeks.org/java/blockingdeque-size-method-in-java-with-examples/

⇱ BlockingDeque size() method in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

BlockingDeque size() method in Java with Examples

Last Updated : 14 Oct, 2019
The size() method of BlockingDeque returns the current size of the Deque container. On calling the function the number of elements in the Deque container is returned. If the container is capacity restricted, then also it returns the number of elements which are present in the container at the time of function call. Syntax:
public int size()
Returns: This method returns an integer value which signifies the number of elements in the container. Note: The size() method of BlockingDeque has been inherited from the LinkedBlockingDeque class in Java. Below programs illustrate size() method of BlockingDeque: Program 1:
Output:
Blocking Deque: [15, 20, 20, 15, 15, 20, 20, 15]
Size of Blocking Deque: 8
Program 2:
Output:
Blocking Deque: [geeks, forGeeks, A Computer, Portal]
Size of Blocking Deque: 4
Reference: https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/BlockingDeque.html#size()
Comment