clone() has protected access - made public Object clone()

后端 未结 2 499
醉话见心
醉话见心 2020-12-17 09:49

I\'m writing code to create an object, clone the object, then compare the two.

The object in question, Octagon, is an extension of an object GeometricObject

2条回答
  •  执念已碎
    2020-12-17 10:47

    Replace

    Octagon copy = (Octagon)test.clone();
    

    with

    Octagon copy = (Octagon)((Octagon)test).clone();
    

    so that the called clone method is the one of your class.

提交回复
热议问题