Javatpoint Logo
Javatpoint Logo

Java Deque addLast() Method

The addLast() method of Java Deque Interface is used to insert the specified element at the end of the deque.

Syntax:

Parameter:

The above method consists of only one parameter:

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

Return:

NA

Throw:

IllegalStateException- If the elements cannot be added at the time due to capacity restriction.

ClassCastException- If the class of the specified element avoids it from being added to the deque.

NullPointerException- If the specified element is a null and the deque does not allow the null elements.

IllegalArgumentException- If some of the property of the given element avoids it from being added to the deque.

Example 1

Test it Now

Output:

The elements are adding at the front of the deque : [44, 33, 22, 11]

Example 2

Test it Now

Output:

The subjects are given as : [FAT, CAO, JAVA, DBMS]

Example 3

Output:

Enter the number of times you want to enter the names : 4
The names are : 
Ashu
Hitesh
Jasmeet
Isha
The final deque is : [Ashu, Hitesh, Jasmeet, Isha]
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