Clone1 Java Clone 테스트 package ch09; class Point implements Cloneable { // Cloneable인터페이스를 구현한 클래스에서만 clone()을 호출할 수 있다. 이 인터페이스를 구현하지 않고 clone()을 호출하면 예외가 발생한다. int x; int y; Point(int x, int y) { this.x = x; this.y = y; } public String toString() { return "x="+x +", y="+y; } public Point clone() { Object obj=null; try { obj = super.clone(); } catch(CloneNotSupportedException e) {} // clone메서드에는 CloneNotSupportedExce.. 2011. 5. 8. 이전 1 다음