Javatpoint Logo
Javatpoint Logo

Java Collections asLifoQueue() Method

The asLifoQueue() is an inbuilt method of Java Collections class which returns a view of a Deque as a Last-in-first-out (LIFO) Queue. In this method, the method add and remove is mapped to push and pop operation respectively. It is useful when we want to use a method requiring a Queue but we need LIFO order.


Following is the declaration of asLifoQueue() method:


Parameter Description Required/Optional
dequeue Dequeue the provided collection List. Required


The asLifoQueue() method returns queue list as a result of the method call.



Compatibility Version

Java 1.6 and above

Example 1

Test it Now


The resultant queue is: [Java, C, C++, Unix, Perl]

Example 2

Test it Now


The resultant view of the queue is: [1, 2, 3, 4, 5]

Example 3

Test it Now


Initial view of the queue is: [1, 2]
New queue value is: [1, 2, 3]
The resultant view of the queue is: [5, 4, 1, 2, 3]

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA