Java Collections asLifoQueue() MethodThe 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. SyntaxFollowing is the declaration of asLifoQueue() method: Parameter
ReturnsThe asLifoQueue() method returns queue list as a result of the method call. ExceptionsNA Compatibility VersionJava 1.6 and above Example 1Test it NowOutput: The resultant queue is: [Java, C, C++, Unix, Perl] Example 2Test it NowOutput: The resultant view of the queue is: [1, 2, 3, 4, 5] Example 3Test it NowOutput: 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] Next TopicJava Collections Class |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India