The copy constructor usually needs to copy the instance variables and, if necessary, some deep state - do not store the link to the source object.
, . - , if, , , , /.
public class Board {
protected int size;
protected Cell[][] grid;
public Board (int N) {
this.size = N;
this.grid = new Cell[size][size];
}
public Board (Board orig) {
this.size = orig.size();
this.grid = new Cell[size][];
for (int i = 0; i < size; i++) {
grid[i] = Arrays.copyOf( orig.grid[i], size);
}
}
public int size() {return size;}
}
protected , .
, ( ) this.. .
; . . , add (List<Customer> customers) customerList.