I want to clone any LinkedList, whether or not it holds things which can be primitive wrappers. I understand it can be a deep recursive call to get a true deep clone - but I want just one level of cloning. I cannot compile the following code :
<T> LinkedList<T> deepCloneOneLevel (final LinkedList<T> input){
if(input != null){
LinkedList<T> clone = new LinkedList<>();
for (T t: input){
clone.add(t.clone()); //error : clone() has protected access
}
return clone;
}
return null;
}