Java LinkedBlockingDeque pollLast() MethodThe pollLast() method of LinkedBlockingDeque class retrieves the last element of this deque, and also removes it. This method returns null if this deque is empty. The pollLast(long timeout, TimeUnit unit) method of LinkedBlockingDeque class retrieves the last element of this deque, awaiting till the specified time is essential for an element to be available. Syntax:Parameters:
Specified By:The pollLast() method of LinkedBlockingDeque class is specified by :
Return Value:The pollLast() method returns this deque'stail, and if this deque is empty returns null. The pollLast(long timeout, TimeUnit unit) method returns this deque's tail, or null if the assigned waiting time passes before the element is available. Throws:The pollLast() method throws InterruptedException if the method is disrupted while waiting. Example 1Test it NowOutput: Last element of the dequeis : Ramesh Elements left in deque : [Himanshu, Rahul, Rita] Example 2Test it NowOutput: Jyoti gets the lowest wages of 1000 Vineet gets the second lowest wages of 1500 Example 3Test it NowOutput: Last element of the deque : 876 Elements in deque : [67, 109, 76] 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