Java Collection Tutorial - Java Deque.addLast(E e)








Syntax

Deque.addLast(E e) has the following syntax.

void addLast(E e)

Example

In the following code shows how to use Deque.addLast(E e) method.

/*from  www .  j a  va 2s  . com*/
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {
   public static void main(String[] args) {
      
      
      Deque<Integer>  deque = new ArrayDeque<Integer> (8);

      
      deque.add(20);
      deque.add(30);
      deque.add(20);
      deque.add(18);        
      deque.add(22);
      deque.add(24);

      deque.addLast(10);
      deque.addLast(12);
      
      System.out.println(deque);
   }
}

The code above generates the following result.