Monday, 6 July 2015

Java : Collection Framework : Collections (asLifoQueue)


Click here to watch in Youtube : 
https://www.youtube.com/watch?v=SsLt48OsM_c&list=UUhwKlOVR041tngjerWxVccw

CollectionsExample.java
import java.util.Collections;
import java.util.Deque;
import java.util.LinkedList;
import java.util.Queue;

/*
 Method: 

 public static <T> Queue<T> asLifoQueue(Deque<T> deque)

 Parameters:

 deque - the deque

 Returns:

 the queue

 */

public class CollectionsExample
{

    public static void main(String[] args)
    {

        Deque<Integer> deque = new LinkedList<Integer>();
        deque.add(100);
        deque.add(200);
        deque.add(300);
        deque.add(400);

        System.out.println("deque : " + deque+"\n");
        
        /*
         * Returns a view of a Deque as a Last-in-first-out (Lifo) Queue.
         */
        Queue<Integer> queue = Collections.asLifoQueue(deque);

        System.out.println("queue : " + queue);

    }
}
Output
deque : [100, 200, 300, 400]

queue : [100, 200, 300, 400]
To Download CollectionsDemo-asLifoQueue Project Click the below link
https://sites.google.com/site/javaee4321/java-collections/CollectionsDemo-asLifoQueue.zip?attredirects=0&d=1

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment

    Google+ Followers

    Google+ Badge