0

I have a variable of type List<RelationHeader>. Now I want to copy all the elements in this list to a new list, but I want to actually copy all the members by value (clone them). Is there a quick command to do this, or do I need to iterate over the list and copy them one at a time?

Amir Rachum
  • 76,817
  • 74
  • 166
  • 248

1 Answers1

2

You'll have to do this manually. There's no generally accepted way of deep-copying objects in Java (clone() is not really used for this - see this Joshua Bloch article) and you'll have to determine yourself how deep you want to copy those objects.

Brian Agnew
  • 268,207
  • 37
  • 334
  • 440