中的給定參數將對象添加到ArrayList我想模擬Java中的排隊系統。我無法通過方法
public void enqueue(Packet...packets)
{
// here the Packet object needs to be added to an existing ArrayList..
}
我試圖增加包在我現有的ArrayList queue
queue.add(packets)
如下但這不起作用。
我該如何做到最好?我不能給ArrayList
作爲參數,它必須是Packet...packets
。
檢查http://stackoverflow.com/questions/3158730/java-3-dots-in-parameters – sam