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?
            Asked
            
        
        
            Active
            
        
            Viewed 1,060 times
        
    0
            
            
         
    
    
        Amir Rachum
        
- 76,817
- 74
- 166
- 248
- 
                    1See: http://stackoverflow.com/questions/715650/java-how-to-clone-arraylist-but-also-clone-its-items – Jonathan Holloway Apr 25 '10 at 19:33
1 Answers
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