- 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
LinkedTransferQueue in Java
The LinkedTransferQueue Class in Java has a transfer queue that has unbounded functionality and is based on linked nodes. It uses FIFO for ordering elements. 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.LinkedTransferQueue; public class Demo { public static void main(String[] args) throws InterruptedException { LinkedTransferQueue<String> ltQueue = new LinkedTransferQueue<String>(); ltQueue.add("Amy"); ltQueue.add("John"); ltQueue.add("May"); ltQueue.add("Harry"); ltQueue.add("Anne"); System.out.println("The elements in LinkedTransferQueue are: " + ltQueue); } }
The output of the above program is as follows −
Output
The elements in LinkedTransferQueue are: [Amy, John, May, Harry, Anne]
Now let us understand the above program.
The LinkedTransferQueue is created and then elements are added to it. Finally it is displayed. A code snippet that demonstrates this is given as follows −
LinkedTransferQueue<String> ltQueue = new LinkedTransferQueue<String>(); ltQueue.add("Amy"); ltQueue.add("John"); ltQueue.add("May"); ltQueue.add("Harry"); ltQueue.add("Anne"); System.out.println("The elements in LinkedTransferQueue are: " + ltQueue);
Advertisements
To Continue Learning Please Login
Login with Google