Here you can find the source of getAllElementsFromQueueAsList(Queue
public static <Type> List<Type> getAllElementsFromQueueAsList(Queue<Type> queue)
//package com.java2s; //License from project: LGPL import java.util.ArrayList; import java.util.List; import java.util.Queue; public class Main { public static <Type> List<Type> getAllElementsFromQueueAsList(Queue<Type> queue) { final int size = queue.size(); List<Type> result = new ArrayList<>(); for (int i = 0; i < size; i++) { result.add(queue.poll());//w w w . ja v a 2 s . c o m } return result; } }