我遇到了一个情况,我很困惑。请帮帮我。假设我有这样的代码。
MyClass obj1 = null;
List<MyClass> testList = new ArrayList<MyClass>();
testList.add(obj1);//after this line of code, testList will have a "null" at first node
obj1 = new MyClass();//after this line of code, testList still have a "null"
                     //at first node...
                     //What I want is that testList's first node will become a new 
                     //MyClass object
这是我理解的步骤(可能不正确......):
- obj1存储指向空的指针...
 - testList存储指向包含“new ArrayList()”的内存的指针
 - testList在其集合中添加obj1的指针。
 - obj1存储指向“new MyClass()”的指针
 - 因此,testList中的obj1应该自动指向“new MyClass()”
 
对不起,我是编程新手......感谢任何帮助!