Java Deque offer() MethodThe offer() method of Java Deque Interface inserts the given element into the queue which is represented by the particular deque. Specified by:offer in interface Queue<E> Syntax:Parameter:The above method requires only one parameter :
Return:The above method is used to return a Boolean value, i.e., true if the element is added to the queue. Otherwise, returns false. Throw:ClassCastException- If the class for the given element avoids it from being added to the deque. NullPointerException- If the specified element is a null and the given deque does not allow the null elements. IlleagalArgumentException- If some properties of the specified element prevents it from being added to the deque. Example 1Test it NowOutput: The final deque is given as : Tina Shyam Isha Falguni Example 2Test it NowOutput: The final deque is given as : [34, 43, 22, 55] 34 43 22 55 Example 3Test it NowOutput: The final deque is given as : H E L L O 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