Example usage for java.util Collections asLifoQueue

List of usage examples for java.util Collections asLifoQueue

Introduction

In this page you can find the example usage for java.util Collections asLifoQueue.

Prototype

public static <T> Queue<T> asLifoQueue(Deque<T> deque) 

Source Link

Document

Returns a view of a Deque as a Last-in-first-out (Lifo) Queue .

Usage

From source file:Main.java

public static void main(String args[]) {

    Deque<Integer> deque = new ArrayDeque<Integer>(7);

    deque.add(1);//w ww  . j av a 2s.  co  m
    deque.add(2);
    deque.add(3);
    deque.add(4);
    deque.add(5);

    // get queue from the deque
    Queue<Integer> nq = Collections.asLifoQueue(deque);

    System.out.println("View of the queue is: " + nq);
}