我有一个数组列表:
ArrayList ReceivedPackets = new ArrayList();
我还有另一个 ArrayList:
ArrayList returnList = ReceivedPackets;
为什么在我运行此代码时returnList 会失去它的价值?
ArrayList ReceivedPackets = new ArrayList(); // ReceivedPackets is empty
ReceivedPackets.Add(1); // Now it has an Integer
ArrayList returnList = ReceivedPackets; // Call-by-Reference (I thought), returnList now has an Integer
ReceivedPackets.clear(); // returnList is empty now. Why?