I am trying to clone a list of Cloneables:
public static <T extends Cloneable> List<T> cloneList(List<T> list)
{
List<T> out = new ArrayList<T>();
for(int i=0;i<list.size();i++)
{
out.add((T)((T)list.get(i)).clone());
}
return out;
}
which throws the error:
Helpers.java:40: error: cannot find symbol
out.add((T)((T)list.get(i)).clone());
^
symbol: method clone()
location: interface Cloneable
Why is that; isn't clone()
the single method the Cloneable
interface is all about?