VOOZH about

URL: https://www.geeksforgeeks.org/java/concurrentlinkeddeque-getfirst-method-in-java/

⇱ ConcurrentLinkedDeque getFirst() method in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

ConcurrentLinkedDeque getFirst() method in Java

Last Updated : 17 Sep, 2018
The java.util.concurrent.ConcurrentLinkedDeque.getFirst() method is an in-built method in Java which returns the first element of the deque container. Syntax:
Conn_Linked_Deque.getFirst()
Parameters: The method does not accept any parameter. Return Value: The method returns the first element present in the Deque. Exception: The function throws a NoSuchElementException when the deque is empty. Below programs illustrate the ConcurrentLinkedDeque.getFirst() method : Program 1:
Output:
Elements in the Deque: [Welcome, To, Geeks, 4, Geeks]
The first element is: Welcome
Program 2:
Output:
java.util.NoSuchElementException
Elements in the Deque: [12, 43, 29, 16, 70]
The first element is: 12
Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentLinkedDeque.html#getFirst()
Comment