嗨我想知道是否可以將ArrayList分配給Java中的另一個ArrayList(如指針?)。將陣列列表分配給陣列列表
下面是一個例子來說明我的觀點
public class FooBar
{
boolean Foo = true;
public ArrayList<String> listA = new ArrayList<String>();
public ArrayList<String> listB = new ArrayList<String>();
public void Bar()
{
ArrayList<String> whichList;
if(Foo)
whichList = listA;
else
whichList = listB;
for(String words : whichList)
{
// ...
}
}
}
將這項工作?
如果通過這將是更有教育意義的,你只要試試看看會發生什麼。您也可以使用它作爲學習如何在IDE調試器中逐步完成代碼的機會。實驗的意願是成爲軟件開發人員的基本要求。 –
是@JimGarrison是對的! –
請檢查http://stackoverflow.com/questions/8441664/how-do-i-copy-the-contents-of-one-arraylist-into-another –