Java Deque offerLast() Method
The offerLast() method of Java Deque Interface is used to insert the given element at the end of the deque unless and until it violates the capacity restriction. While using a capacity-restricted deque, this method is preferred over addLast(E) method.
The above requires only one parameter:
The above method is used to return true if the element is already added in the queue. Otherwise, the method returns false.
ClassCastException- If the class for the given element avoids it from being added to the given deque.
NullPointerException- If the specified element is already null and the given deque does not allow the null elements.
IlleagalArgumentException- If some properties of the specified element prevent it from being added to the deque.
The deque is : [45.6, 23.0, 45.8, 66.9]
Example 2Test it Now
The list of the elements is given as : [23, 45, 67, 98]
Example 3Test it Now
Java is a secured language. The required string is given as : [Java, is, a, secured, language.]