11:03 am - Sunday April 30, 2017

View of Deque in Last-in-first-out order using asLifoQueue()

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

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]

BACK

Filed in: Java Examples

Comments are closed.