ArrayList 的深拷贝 <Integer>

Deep copy of an ArrayList <Integer>

我想将 ArrayList zf 复制到 ArrayList copyzf 中。文案一定要深的

我已经试过了:

public class ZFW {
  Integer zfw;
 public ZFW copy() {
  ZFW m= new ZFW();
  m.zfw=this.zfw.copy();
  return m;
 }
}

在执行代码中:

 for(int r=0; r<zf.size();r++) {
    Integer z;
    z=zf.get(r);
    copyzf.set(r, z.copy());
   }

出现错误"The method copy() is undefined for the type Integer"。我无法更改 ArrayLists 的数据类型,有人知道我该如何解决问题吗?提前致谢!

整数是不可变的,所以深拷贝是没有用的。提到的 ArrayList?

在您的代码中的哪个位置