Lists and maps in Java
I am just trying to get everything straight in my mind. When I use lists or maps in Java, the maps and lists don't actually store a copy of the object, right? They just contain a pointer to them? I think that is how i开发者_如何学编程t is, I just wanted to check and solidify my knowledge.
Yes, a reference to the Object is stored. You can manipulate the object outside of the Map or List and the updated Object will returned when you get it from the Map or List
yes they do if you want to make copy of an object use the clone()
method which return a new object , but you must consider implement it for your custom classes
精彩评论