I deep copied a list of objects into another list.
The problem is using .contains()
didn't work! Any ideas?
Asked
Active
Viewed 117 times
-6
-
6Need more than just wording.. – Smit Jan 29 '13 at 00:11
-
4How could we possibly help you without any code, any idea what objects you're deep copying, or anything along those lines? – Louis Wasserman Jan 29 '13 at 00:11
-
7I bet this error occurs because `equals()` is not overridden in the class stored in the list. – jlordo Jan 29 '13 at 00:12
1 Answers
4
In order for this to work you need to override hashcode and equals on the contents of the list. Contains uses these methods, which by default are based on the memory reference so it will only work for a shallow copy.

LINEMAN78
- 2,562
- 16
- 19