Java Collections.asLifoQueue(Deque <T> deque)
Syntax
Collections.asLifoQueue(Deque <T> deque) has the following syntax.
public static <T> Queue <T> asLifoQueue(Deque <T> deque)
Example
In the following code shows how to use Collections.asLifoQueue(Deque <T> deque) method.
//from w w w . j a v a 2 s .c om
import java.util.ArrayDeque;
import java.util.Collections;
import java.util.Deque;
import java.util.Queue;
public class Main {
public static void main(String args[]) {
Deque<Integer> deque = new ArrayDeque<Integer> (7);
deque.add(1);
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);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »