Item 13. clone 오버라이딩은 주의해서 진행하라
clone
protected Object clone() throws CloneNotSupportedException {}Cloneable의 올바른 사용 예
Cloneable의 올바른 사용 예class Item13 implements Cloneable {
@Override
public Item13 clone() {
try {
return (Item13) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError();
}
}
}복사 생성자, 복사 팩터리
복사 생성자
복사 팩터리
복사 생성자, 복사 팩터리의 장점
Last updated