Java Deque offerFirst() MethodThe offerFirst() method of Java Deque Interface is used to insert the given element in the front of the deque unless and until it violates the capacity restrictions. While using a capacity restricted deque , the above method is used for addFirst(E) method. 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 : A V A J Example 2Test it NowOutput: The final deque is given as : language secured a is Java Example 3Test it NowOutput: The final deque is given as : 5 4 3 2 1 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