I am having a list of company objects. I am trying to clone this list with:
public static List<Company> cloneList(List<Company> list) {
List<Company> clone = new ArrayList<Company>(list.size());
for(Company item: list) clone.add(item.clone());
return clone;
}
However my compiler says:
Multiple markers at this line
- The method add(Company) in the type List<Company> is not applicable for the arguments
(Object)
Why is this not possible to make a deep copy with clone()
?