반응형

얇은 복사 (shallow copy)

깊은 복사 (deep copy)

 

static Point[] shallowCopy(Point[] a) {
    Point[] b = new Point[a.length];
    for (init i = 0; i < a.lenhth; ++i)
        b[i] = a[i];
    return b;
}

static Point[] shallowCopy(Point[] a) {
    Point[] b = new Point[a.length];
    for (init i = 0; i < a.lenhth; ++i)
        b[i] = a[i].clone();
    return b;
}

반응형