Hi I used add and offer to add my element in last pace. Both are returning boolean and both does not throw any exception apart from NPE.
public class ArrayDequeDemo {
public static void main(String[] args) {
// Create ArrayDeque elements.
ArrayDeque<Integer> deque = new ArrayDeque<>();
deque.add(10);
deque.offer(30);
}
}
Both will add element in last place by returning a boolean.
JAVA IMPLEMENTATION
//For Add and Offer Both
public void addLast(E e) {
if (e == null)
throw new NullPointerException();
elements[tail] = e;
if ( (tail = (tail + 1) & (elements.length - 1)) == head)
doubleCapacity();
}
doubleCapacity()
method and also documentation in Deque Interface.