LinkedTransferQueue poll() method in Java
The java.util.concurrent.LinkedTransferQueue.poll() method is an in-built function in Java which retrieves and remove the head of the queue if the queue is non-empty.
Parameters: The function does not accept any parameter.
Return Value: The function returns the head of the queue if the queue is non-empty, otherwise it returns null.
Below programs illustrate the LinkedTransferQueue.poll() method:
The head of the queue is A The elements in the queue : B C D E F G H I J K L M N O P Q R S T U V W X Y Z
The head of the queue is 10 The elements in the queue : 20 30 40 50
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.