ConcurrentLinkedDeque peekLast() method in Java Last Updated : 26 Nov, 2018 Comments Improve Suggest changes Like Article Like Report The java.util.concurrent.ConcurrentLinkedDeque.peekLast() is an in-built method in Java which retrieves the last element of this deque container without removing it. The function returns NULL if the deque is empty. Syntax: Conn_Linked_Deque.peekLast() Parameters: The function does not accepts any parameter. Return Values: The function returns the last element present in this deque and returns NULL when the deque is empty. Below programs illustrate the use of peekLast() method: Program 1: This program involves deque with Integer elements. Java // Java Program Demonstrate peekLast() // method of ConcurrentLinkedDeque import java.util.concurrent.*; class ConcurrentLinkedDequeDemo { public static void main(String[] args) { ConcurrentLinkedDeque<Integer> cld = new ConcurrentLinkedDeque<Integer>(); cld.addFirst(12); cld.addFirst(110); cld.addFirst(55); cld.addFirst(76); // Displaying the existing LinkedDeque System.out.println("Elements in" + "the LinkedDeque: " + cld); // Displaying the last element System.out.println("Last Element in" + "the LinkedDeque: " + cld.peekLast()); } } Output: Elements inthe LinkedDeque: [76, 55, 110, 12] Last Element inthe LinkedDeque: 12 Program 2: This program involves deque with String elements. Java // Java Program Demonstrate peekLast() // method of ConcurrentLinkedDeque import java.util.concurrent.*; class ConcurrentLinkedDequeDemo { public static void main(String[] args) { ConcurrentLinkedDeque<String> cld = new ConcurrentLinkedDeque<String>(); cld.addFirst("GFG"); cld.addFirst("Gfg"); cld.addFirst("GeeksforGeeks"); cld.addFirst("Geeks"); // Displaying the existing LinkedDeque System.out.println("Elements in" + "the LinkedDeque: " + cld); // Displaying the last element System.out.println("Last Element in" + "the LinkedDeque: " + cld.peekLast()); } } Output: Elements inthe LinkedDeque: [Geeks, GeeksforGeeks, Gfg, GFG] Last Element inthe LinkedDeque: GFG Reference:https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentLinkedDeque.html#peekLast() Comment More infoAdvertise with us Next Article ConcurrentLinkedDeque peekLast() method in Java R RICHIK BHATTACHARJEE Follow Improve Article Tags : Misc Java Java-Collections Java - util package Java-Functions Java-ConcurrentLinkedDeque +2 More Practice Tags : JavaJava-CollectionsMisc Similar Reads ConcurrentLinkedDeque peekFirst() method in Java The java.util.concurrent.ConcurrentLinkedDeque.peekFirst() is an in-built method in Java which retrieves the first element of this deque without removing it. The function returns NULL if the deque is empty. Syntax: Conn_Linked_Deque.peekFirst() Parameters: This function does not accepts any paramete 2 min read ConcurrentLinkedDeque pollLast() method in Java The java.util.concurrent.ConcurrentLinkedDeque.pollLast() is an in-built method in Java which retrieves the last element of this deque and removes it. If the deque is empty, the method returns NULL. Syntax: Conn_Linked_Deque.pollLast() Parameters: The function accepts no parameters. Return Values:Th 2 min read ConcurrentLinkedDeque removeLast() method in Java The ConcurrentLinkedDeque.removeLast() is an in-built function in Java which removes the last element in the deque. The function throws a NoSuchElementException if this deque is empty. Syntax: Conn_Linked_Deque.removeLast() Parameters: The function does not accepts any parameter. Return Values: The 2 min read ConcurrentLinkedDeque offerLast() Method in Java The java.util.concurrent.ConcurrentLinkedDeque.offerLast() method is an inbuilt method in Java which inserts the specified element, passed as a parameter, to the end of the deque. Syntax: Conn_Linked_Deque.offerLast(Object elem) Parameters: The method accepts a parameter elem which species the eleme 2 min read ConcurrentLinkedQueue peek() method in Java The peek() method of ConcurrentLinkedQueue is used to return the head of the ConcurrentLinkedQueue. It retrieves but does not remove, the head of this ConcurrentLinkedQueue. If the ConcurrentLinkedQueue is empty then this method returns null. Syntax: public E peek() Returns: This method returns the 2 min read Like