문제

I don't understand why we can't do the following:

interface MyInterface extends Cloneable {}

class myClazz implements MyInterface {
    public Object clone() { return null; }
}

class test{
    public static void main(String[]a){
        MyInterface o = new myClazz();
        o.clone(); // IMPOSSIBLE
    }
}

But this will work fine

interface Misc{
    public void testM();
}

interface MyInterface extends Misc{}

class myClazz implements MyInterface {
    public void testM() {}
}

class test{
    public static void main(String[]a){
        MyInterface o = new myClazz();
        o.testM(); // OK
    }
}

What's happen with Cloneable?

Thanks,

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top