Java Deque offerLast() MethodThe 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. Syntax:Parameter:The above requires only one parameter:
Return:The above method is used to return true if the element is already added in the queue. Otherwise, the method returns false. Throw: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. Example 1Output: The deque is : [45.6, 23.0, 45.8, 66.9] Example 2Test it NowOutput: The list of the elements is given as : [23, 45, 67, 98] Example 3Test it NowOutput: Java is a secured language. The required string is given as : [Java, is, a, secured, language.] 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