Queue
Queue
import java.util.*;

public class Q
{
	public static void main(String args[])
	{
		Queue<Integer> q = new LinkedList<Integer>();

		//add
		for(int i = 0; i < 10; i++)
			q.add(i);

		//toString
		System.out.println(q);

		//peek
		System.out.println("Front: "+q.peek());

		//remove
		while(!q.isEmpty())
		{
			System.out.printf("%4d", q.remove());
		}
		System.out.println();
	}
}
			
PriorityQueue
import java.util.*;

public class Q
{
	public static void main(String args[])
	{
		PriorityQueue<String> q = new PriorityQueue<String>();

		q.add("Java");
		q.add("C++");
		q.add("Python");
		q.add("MATLAB");

		//peek
		System.out.println("Peek: "+q.peek());

		//for each
		for(String e : q)
			System.out.printf("%10s", e);//C++ Java Python MATLAB
		System.out.println();

		//poll
		for(int i = 0, len = q.size(); i < len; i++)
			System.out.println("Poll: "+q.poll());//C++ Java MATLAB Python
	}
}
			
Deque
import java.util.*;

public class Q
{
	public static void main(String args[])
	{
		Deque<Integer> q = new LinkedList<Integer>();

		for(int i = 0; i < 10; i++)
			q.add(i);

		//addFirst
		q.addFirst(20);

		//addLast
		q.addLast(30);
		System.out.println(q);

		//getFirst
		System.out.println("First: "+q.getFirst());

		//getLast
		System.out.println("Last: "+q.getLast());

		//pollFirst
		System.out.println("Poll First: "+q.pollFirst());

		//pollLast
		System.out.println("Poll Last: "+q.pollLast());

		System.out.println(q);
	}
}