嗨我想知道是否可以将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 –