嗨在這裏,我試圖從列表中列出項目,併爲每個迭代打印5。 這裏在下面的代碼是打印相同的項目每次與ArrayList和列表的區別
for(int i=0;i<4;i++)
{
List<Card> l=a.subList(a.size()-5, a.size());
System.out.println(l);
}
但這裏是印刷不同的項目,就好像它是從列表中的每個時間
for(int i=0;i<4;i++){
int deckSize = a.size();
List<Card> handView = a.subList(deckSize-5, deckSize);
ArrayList<Card> hand = new ArrayList<Card>(handView);
handView.clear();
System.out.println(hand);
}
之間有什麼區別除去5上面兩段代碼
兩者都很奇怪。你想做什麼? – 2011-03-17 10:11:38
這是你的'handView.clear();'去除了物品。 – asgs 2011-03-17 10:11:48
第二個是我從教程中看到的...第一個我正在嘗試做 – satheesh 2011-03-17 10:16:38