Retrieves
and removes the last element of this deque. This method differs from
pollLast()
only in that it throws an exception if this deque is empty.
package com.logicbig.example.arraydeque;
import java.util.ArrayDeque;
import java.util.List;
public class RemoveLastExample2 {
public static void main(String... args) {
ArrayDeque<Integer> ad = new ArrayDeque<>();
System.out.println(ad);
Integer e = ad.removeLast();
System.out.println(e);
}
}
Output
Caused by: java.util.NoSuchElementException
at java.base/java.util.ArrayDeque.removeLast(ArrayDeque.java:369)
at com.logicbig.example.arraydeque.RemoveLastExample2.main(RemoveLastExample2.java:16)
... 6 more