BACK
The asLifoQueue(Deque<T>) method is used to get a view of a Deque as a Last-in-first-out Queue.The method of Queue should be in lifo order.
Example Program
import java.util.Collections; import java.util.ArrayDeque; import java.util.Queue; public class collectionLifoQueue { public static void main(String[] args) { ArrayDeque v = new ArrayDeque(3); v.add("Happy"); v.add("Sad"); v.add("Joy"); Queue b = Collections.asLifoQueue(v); System.out.println("The queue is: " + v); } }
Output
The queue is: [Happy, Sad, Joy]