Javatpoint Logo
Javatpoint Logo

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:

  1. The element 'e' that needs to be added.

Return:

The above method returns a Boolean value, i.e., true.

Example 1

Test it Now

Output:

Week : [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday]

Example 2

Test it Now

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





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA