편집 : 개체를 복제해야 할 때이 문제가 발생하고 검색했지만 문제가 해결되지 않았습니다.Java : 복제 전에 유형 캐스트?
Java에서 프로토 타입 패턴을 학습 할 때 일부 자습서를 따라 가면서 (Bike)super.clone()
의 형식 변환에 대해 혼란스러워합니다.
먼저 수행되는 작업은 무엇입니까? (Bike)super
또는 super.clone()
? 왜 (Bike)
이 필요한가요?
public interface Prototype extends Cloneable
{
public Prototype clone() throws CloneNotSupportedException;
}
public class Bike implements Prototype
{
// Constructor and other methods...
// My question is here
public Prototype clone() throws CloneNotSupportedException {
return (Bike)super.clone();
}
}
가능한 [Java casting order] 복제본 (http://stackoverflow.com/questions/5762270/java- casting-order) – Tom