Programming/Java

Object.clone()

구차니 2019. 1. 9. 21:00

크.. 망할 자바 ㅠㅠ


아무생각 없이 Point 객체를 = 으로 넣어서 복사될 줄 알았는데

(아니 이렇게 관대한 녀석 아니었어?)

계속 값이 초기화 되서 지인에게 물어봤더니 clone()을 쓰라고..


일단은.. call by reference인지 call by value 인지 조금 더 공부해봐야겠다.. -_ㅠ


protected Object clone()

                throws CloneNotSupportedException

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression: 

[링크 : https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#clone()]