Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Deque interface in Java

// Java program to demonstrate the working
// of a Deque in Java
 
import java.util.*;
 
public class DequeExample {
    public static void main(String[] args)
    {
        Deque<String> deque
            = new LinkedList<String>();
 
        // We can add elements to the queue
        // in various ways
 
        // Add at the last
        deque.add("Element 1 (Tail)");
 
        // Add at the first
        deque.addFirst("Element 2 (Head)");
 
        // Add at the last
        deque.addLast("Element 3 (Tail)");
 
        // Add at the first
        deque.push("Element 4 (Head)");
 
        // Add at the last
        deque.offer("Element 5 (Tail)");
 
        // Add at the first
        deque.offerFirst("Element 6 (Head)");
 
        System.out.println(deque + "
");
 
        // We can remove the first element
        // or the last element.
        deque.removeFirst();
        deque.removeLast();
        System.out.println("Deque after removing "
                           + "first and last: "
                           + deque);
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: sha-1 key generator 
Java :: power of a number in java 
Java :: Demo Example 
Java :: Remove ArrayList Elements using remove() function 
Java :: XmlRootElement Object to String 
Java :: java stream list order lambda 
Java :: open google maps cycling navigation intent 
Java :: javacal 
Java :: format string precision double java 
Java :: Java public no-arg constructors 
Java :: java map get if contains else 0 
Java :: SmallChange 
Java :: string equlity 
Java :: constraint layout not matching parent in netsted scrollview 
Java :: one to many relation between objects 
Java :: java t point c# 
Java :: change order of words in string java 
Java :: android diagonal gradle 
Java :: Java Protected Access Modifier package two 
Java :: hybrid inheritance in java 
Java :: leak canary 
Java :: enum to get status name from list using status id 
Java :: log errors with stack traces spring 
Java :: tipe data c++ 
Java :: java quote of the day 
Java :: android how to change focus on confirm button on keyboard 
Java :: consumer 
Java :: best wireless headphoenes under 200 
Java :: exception(string message throwable cause) 
Java :: reading data from wsdl in java 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =