The Deque.addLast(element)
method is present in the Deque
interface inside the java.util
package.
Deque.addLast(element)
is used to insert the element at the end of the deque if the deque is not full.
boolean addLast(element)
The Deque.addLast(element)
method takes one parameter:
element
: This is an element to be inserted.The Deque.addLast(element)
method returns a Boolean value:
true
: When the element is inserted successfully in the deque.false
: When the element is not inserted in the deque.Let’s take a look at the code widget below:
import java.util.*;class Main{public static void main(String[] args){Deque<Integer> d = new LinkedList<Integer>();d.add(212);d.add(23);d.addLast(621);d.addLast(128);System.out.println("Elements in the deque are: "+d);}}
Main
class.main
function.Integer
type elements.Deque.add()
method.Deque.addLast()
method.