BlockingDeque size() method in Java with Examples Last Updated : 14 Oct, 2019 Comments Improve Suggest changes Like Article Like Report 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: Java // Java Program to demonstrate public int size() // method of BlockingDeque import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.BlockingDeque; import java.util.*; public class GFG { public static void main(String[] args) throws InterruptedException { // create object of BlockingDeque BlockingDeque<Integer> BD = new LinkedBlockingDeque<Integer>(); // Add numbers to end of BlockingDeque BD.add(15); BD.add(20); BD.add(20); BD.add(15); BD.add(15); BD.add(20); BD.add(20); BD.add(15); // print Deque System.out.println("Blocking Deque: " + BD); // prints the Deque after removal System.out.println("Size of Blocking Deque: " + BD.size()); } } Output: Blocking Deque: [15, 20, 20, 15, 15, 20, 20, 15] Size of Blocking Deque: 8 Program 2: Java // Java Program to demonstrate public int size() // method of BlockingDeque import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.BlockingDeque; import java.util.*; public class GFG { public static void main(String[] args) throws InterruptedException { // create object of BlockingDeque BlockingDeque<String> BD = new LinkedBlockingDeque<String>(); // Add numbers to end of BlockingDeque BD.add("geeks"); BD.add("forGeeks"); BD.add("A Computer"); BD.add("Portal"); // print Dequeue System.out.println("Blocking Deque: " + BD); // prints the Deque after removal System.out.println("Size of Blocking Deque: " + BD.size()); } } 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 More infoAdvertise with us G gopaldave Follow Improve Article Tags : Java Java - util package Java-Functions Java-BlockingDeque Practice Tags : Java Explore BasicsIntroduction to Java4 min readJava Programming Basics9 min readJava Methods7 min readAccess Modifiers in Java6 min readArrays in Java9 min readJava Strings8 min readRegular Expressions in Java7 min readOOPs & InterfacesClasses and Objects in Java10 min readJava Constructors10 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages7 min readJava Interface11 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java6 min readIterator in Java5 min readJava Comparator Interface6 min readException HandlingJava Exception Handling8 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial15+ min readSynchronization in Java10 min readFile Handling in Java5 min readJava Method References9 min readJava 8 Stream Tutorial15+ min readJava Networking15+ min readJDBC Tutorial12 min readJava Memory Management4 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples8 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions7 min readJava Quiz | Level Up Your Java Skills1 min readTop 50 Java Project Ideas For Beginners and Advanced [Update 2025]15+ min read Like