我有一个抽象类,我想将其初始化为扩展它的类。
我有子类名称作为字符串。
除此之外...
String childClassString;
MyAbstractClass myObject;
if (childClassString = "myExtenedObjectA")
myObject = new ExtenedObjectA();
if (childClassString = "myExtenedObjectB")
myObject = new ExtenedObjectB();
我怎样才能做到这一点?基本上,我该如何摆脱if语句?
慕桂英546537
米琪卡哇伊
翻翻过去那场雪
随时随地看视频慕课网APP
相关分类