Here you can find the source of convertQueueToArray(Queue
public static <K> List<K> convertQueueToArray(Queue<K> q)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; import java.util.PriorityQueue; import java.util.Queue; public class Main { public static <K> List<K> convertQueueToArray(Queue<K> q) { Queue<K> temp = new PriorityQueue<K>(q); List<K> list = new ArrayList<K>(); while (temp.size() > 0) list.add(temp.poll());//from w w w . j a v a 2 s .c om return list; } }