- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
LinkedBlockingDeque in Java
The LinkedBlockingDeque Class in Java has a blockingdeque that is optionally bounded and based on linked nodes. This class implements the Collection interface as well as the AbstractQueue class. It is a part of the Java Collection Framework.
A program that demonstrates this is given as follows −
Example
import java.util.concurrent.LinkedBlockingDeque; public class Demo { public static void main(String[] args) { LinkedBlockingDeque<String> lbDeque = new LinkedBlockingDeque<String>(); lbDeque.add("James"); lbDeque.add("May"); lbDeque.add("John"); lbDeque.add("Sara"); lbDeque.add("Anne"); System.out.println("Size of LinkedBlockingDeque is: " + lbDeque.size()); System.out.println("The elements in LinkedBlockingDeque are: " + lbDeque); } }
The output of the above program is as follows −
Output
Size of LinkedBlockingDeque is: 5 The elements in LinkedBlockingDeque are: [James, May, John, Sara, Anne]
Now let us understand the above program.
The LinkedBlockingDeque is created and then elements are added to it. Then the size of the LinkedBlockingDeque is displayed as well as its elements. A code snippet that demonstrates this is given as follows −
LinkedBlockingDeque<String> lbDeque = new LinkedBlockingDeque<String>(); lbDeque.add("James"); lbDeque.add("May"); lbDeque.add("John"); lbDeque.add("Sara"); lbDeque.add("Anne"); System.out.println("Size of LinkedBlockingDeque is: " + lbDeque.size()); System.out.println("The elements in LinkedBlockingDeque are: " + lbDeque);
Advertisements
To Continue Learning Please Login
Login with Google