Java LinkedBlockingDeque pop() MethodThe pop() method of LinkedBlockingDeque class returns the first element of this deque, and also removes it. The result returned by pop() method is similar to that returned by Deque.removeFirst(). Syntax:Parameters:NA Specified By:The pop() method of LinkedBlockingDeque class is specified by pop() method in interface Deque<E>. Return Value:The pop() method returns the foremost element of this deque. Throws:The pop() method throws NoSuchElementException if this deque is empty. Example 1Test it NowOutput: First element of the dequeis :Himanshu Elements left in deque : [Rahul, Rita, Ramesh] Example 2Test it NowOutput: Exception in thread "main" java.util.NoSuchElementException at java.util.concurrent.LinkedBlockingDeque.removeFirst(LinkedBlockingDeque.java:453) at java.util.concurrent.LinkedBlockingDeque.pop(LinkedBlockingDeque.java:777) at com.javaTpoint.LinkedBlockingDequePopExample2.main(LinkedBlockingDequePopExample2.java:9) Example 3Test it NowOutput: Reema Panda [email protected] Geetanjali Sharma [email protected] VineetTanjea [email protected] HimanshuBhardwaj [email protected] 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