103
Java Deque add() Method
The add() method of Deque interface is used to insert the specified element into the specified queue represented by the deque and returns true upon success and throws an IllegalStateException if there is no current space available.
Specified by:
- add in interface Collection<E>
- add in interface Queue<E>
Syntax:
Parameter:
The above method consists of only one parameter:
- The element ‘e’ that needs to be added.
Return:
The above method returns a Boolean value, i.e., true.
Example 1
Output:
Week : [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday]
Example 2
Output:
The sequence is given as : 2 4 6 8 10
Example 3
Output:
Enter the name : Tina Shyam Falguni The deque is given as : [Tina, Shyam, Falguni]
Next TopicJava Deque