a = new Item[cap] 由于某些歷史和技術原因,創(chuàng)建泛類型數組在Java中是不允許的。我們需要使用類型轉換: a = (Item[]) new Object[cap]; 《算法第四版》 P83