Java LinkedBlockingDeque pollFirst() MethodThe pollFirst() method of LinkedBlockingDeque class retrieves the first element of this deque, and also removes it. The method returns null if this deque is empty. The pollFirst(long timeout, TimeUnit unit) method of LinkedBlockingDeque class retrieves the first element of this deque, awaiting till the specified time is essential for an element to be available. Syntax:Parameters:
Specified By:The pollFirst() method of LinkedBlockingDeque class is specified by :
Return Value:The pollFirst() method returns this deque's head, and if this deque is empty returns null. The pollFirst(long timeout, TimeUnit unit) method returns this deque's head, or null if the assigned waiting time passes before the element is available. Throws:The pollFirst() method throws InterruptedException if the method is disrupted while waiting. Example 1Test it NowOutput: First element of Deque is: Rahim Deque after using pollFirst() method : [Sagar, Tarun, Vibhav, Zarine, Ashwat] Example 2Test it NowOutput: First element of Deque is: 15246 Deque after using pollFirst() method : [24556, 32784, 41275, 59322, 68844] Next TopicJava LinkedBlockingDeque |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India