Java Deque getFirst() MethodLast Updated : 17 Mar 2025 The getFirst() method of Java Deque Interface retrieves but does not remove the first element of the given deque. The above method differs from peekFirst only in one way that it throws an exception if the deque is empty. Syntax:Parameter:NA Return:The above method returns the head of the deque. Example 1Output: The list of the elements is given as : [44.0, 66.0, 11.0, 99.0] The final result of the deque is given as : 44.0 Example 2Output: The list of the elements is given as : [k, p, m, t] The final result of the deque is given as : k Next TopicJava Deque |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India