Java: How does references to relocatable objects work?

时间:2016-02-12 21:35:01

标签: java

By relocatable objects, I mean objects that can relocate itself in memory when there is not enough consecutive space. (for example ArrayList)

ValueError                                Traceback (most recent call last)
<ipython-input-131-c0d040653e23> in <module>()
----> 1 facets.remove([i[0],i[2]])

ValueError: The truth value of an array with more than one element is ambiguous. 
Use a.any() or a.all()

If I keep adding things to list1, it will eventually relocate because there is not enough continuous address space. Then will list2 and list still point to the same address or not? If so, how is it done underneath?

1 个答案:

答案 0 :(得分:2)

No object can relocate itself. What happens here is that <div ng-controller="AppCtrl"> <div ng-repeat="plant in plantList track by plant.id"> <p>{{plant.name}}</p> <p>{{plant.variety}}</p> <p>{{plant.quantity}}</p> </div> </div> and list1 point to the same object and this object (i.e. the list2) contains another reference to the actual storrage (i.e. the array that is used to store the data). If the list grows too big, the pointer to the storrage array changes, not the location of the ArrayList object itself.