Here you can find the source of toArrayTest(Queue
public static void toArrayTest(Queue<Object> q)
//package com.java2s; //License from project: Open Source License import java.util.Queue; public class Main { public static void toArrayTest(Queue<Object> q) { if (q.toArray().length != 0) { throw new RuntimeException(); }//from www . j av a 2 s. c om Object testObject = new Object(); q.add(testObject); Object[] result = q.toArray(); verify(result.length == 1); verify(result[0] == testObject); } private static void verify(boolean val) { if (!val) { throw new RuntimeException(); } } }