Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

deque in java

Deque<Integer> arrayQueue = new ArrayDeque<>();
Deque<Integer> linkedListQueue = new LinkedList<>();

// these operations are useful and same on both.
arrayQueue.push()/addFirst()/addLast();

arrayQueue.remove()/removeFirst()/removeLast()/pop();

arrayQueue.peek()/peekFirst()/peekLast()/size()/
Comment

dequeue in java

// Java program to demonstrate the
// iteration of elements in deque
  
import java.util.*;
public class ArrayDequeDemo {
    public static void main(String[] args)
    {
        // Initializing an deque
        Deque<String> dq
            = new ArrayDeque<String>();
  
        // add() method to insert
        dq.add("For");
        dq.addFirst("Geeks");
        dq.addLast("Geeks");
        dq.add("is so good");
  
        for (Iterator itr = dq.iterator();
             itr.hasNext();) {
            System.out.print(itr.next() + " ");
        }
  
        System.out.println();
  
        for (Iterator itr = dq.descendingIterator();
             itr.hasNext();) {
            System.out.print(itr.next() + " ");
        }
    }
}
Comment

Java How to use Deque?

// Array implementation of Deque
Deque<String> animal1 = new ArrayDeque<>();

// LinkedList implementation of Deque
Deque<String> animal2 = new LinkedList<>();
Comment

PREVIOUS NEXT
Code Example
Java :: android hide textview 
Java :: java font 
Java :: running time of java program 
Java :: how to download java on mint 
Java :: smaller elements on right hand side leetcode 
Java :: java array kürzen 
Java :: java string to char array 
Java :: how to set view width programmatically in android 
Java :: java 8 remove spaces from string 
Java :: star pattern in java 
Java :: java get domain from url 
Java :: filesaver javafx 
Java :: bloomreach remove property 
Java :: javafx set min window size 
Java :: Spring Boot Hibernate remove underscore naming strategy 
Java :: android navigation bar color change 
Java :: in a junit test how test if empty list is returned 
Java :: get id of html tag by class 
Java :: the result o trim is ignored java 
Java :: android java optional arguments 
Java :: java button actionlistener 
Java :: java add listent to button 
Java :: spinner get item text 
Java :: java generic array 
Java :: java for range loop 
Java :: java loop object 
Java :: add certificate to java truststore 
Java :: spring boot jpa in clause 
Java :: print two varaibles using one statement in java 
Java :: android hide status bar and action bar daynamically 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =