我有以下内容
public interface SuperbInterface
public class A implements SuperbInterface
public class B extends A
public class C extends B
我想实例化,C
但似乎正在得到B
,我做错了什么?
Class classz = Class.forName("C");
SuperbInterface superb = (SuperbInterface)classz.newInstance();
//Here when I debug it seems to be going to B.doWork() methods instead of C.doWork().
superb.doWork();
我唯一能想到的是您没有在C中重写doWork()。
也许您尝试过ot覆盖,但是方法名称或参数有拼写错误?
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句