The size() method of LinkedBlockingDeque 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.
public int size()
Returns: This method returns an integer value which signifies the number of elements in the container.
Below programs illustrate size() method of LinkedBlockingDeque:
Linked Blocking Deque: [15, 20, 20, 15, 15, 20, 20, 15] Size of Linked Blocking Deque: 8
Linked Blocking Deque: [geeks, forGeeks, A Computer, Portal] Size of Linked Blocking Deque: 4
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.