0
不可能准确地找到同样的问题/问题,因为我有,我尝试做的是通过一个类,接口参数到另一个类,也实现了相同的接口,见下面的代码:将类的工具接口转换为另一个构造器实现相同的接口?
public class Combiner implements myInterface {
private final myInterface right;
private final myInterface left;
public Combiner(myInterface right, myInterface left) {
this.right = right;
this.left = left;
System.out.println("In constructor");
}
从另一个类:
try {
MyInterface right = mine1.class.newInstance();
MYInterface left = mine2.class.newInstance();
Combiner comb = new Combiner(right, left);
} catch (Exception e) {
System.err.println(e);
}
mine1:
public class mine1 implements MyInterface { .... }
mine2:
public class mine2 implements MyInterface { ..... }
MyInterface的:
public interface MyInterface { }
获取:java.lang.InstantiationException:com.livingcode.workflow.parts.HotspotSelectionChoice
任何想法,什么是错真的吗?
使用'e.printStackTrace();'(如果您没有正确的日志记录)查看完整的错误消息。 – Kayaman