Java Deque getLast() MethodThe getLast() method of Java Deque Interface retrieves but not remove the last element of the deque. The above method differs from the peekLast only in one way that it throws an exception only if the deque is empty. Syntax:Parameter:N.A. Return:The above method is used to return the tail of the deque. Throw:NoSuchElementException- If the given deque is empty. Example 1Test it NowOutput: The final queue is : [FAT, CAO, JAVA, DBMS] The required answer : DBMS Example 2Test it NowOutput: The list of the elements is given as : [k, p, m, t] The required answer : t Example 3Test it NowOutput: The list of the elements is given as : [2, 3, 4, 5] The required answer : 5 Next TopicJava Deque |
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