I think, the hashCode() of an object could be the same thing of the object address as in C++, so I expected the hashCode of the object remain the same before and after insert the data.
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class Hello {
public static void main(String[] args) {
List<Integer> a = new ArrayList<>(1024);
a.add(0, 1);
System.out.println(a.hashCode());
a.add(1, 2);
System.out.println(a.hashCode());
}
}
but it seems it output a different value, so which means after insert a value, the new list object is a deep copy value of the original one?
Anonymous User
21-Dec-2015