-2

I'd like to copy the ArrayList zf into the ArrayList copyzf. The copy has to be a deep one.

I already tried:

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

and in the executing code:

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

The error "The method copy() is undefined for the type Integer" occurs. I can't change the data type of the ArrayLists, does anybody know how I can solve the Problem? Thanks in advance!

  • please post the tag properly for example in which language you have written your code, also please post the full error here. – varnit Dec 30 '18 at 19:32

1 Answers1

0

Integers are immutable, so a deep copy is useless. Where in your code is the mentioned ArrayList?

Thomas S.
  • 5,804
  • 5
  • 37
  • 72