xxxxxxxxxx
public static <T> T getFromQueue(Queue<T> queue, int index){
if(index>=queue.size()){
throw new IndexOutOfBoundsException("index="+index+",size="+queue.size());
}
Queue<T> queueCopy = new LinkedList<T>(queue);
for(int i=0; i<index; i++){
queueCopy.remove();
}
return queueCopy.peek();
}