假设我的代码是这样的:
ArrayList list = new ArrayList();
Student s = new Student(); // creating object of Student class
myList.add(s); // Here am confused ...
/* myList contains just the reference variable to the Student object, OR
myList contains the actual Student object (memory allocation for name, rollNo etc) ??
*/
简而言之,使用 add() 将对象添加到 ArrayList 时:
ArrayList 是“对对象的引用”的列表或其“实际对象”的列表???