关于最后c1.newInstance的疑问
最后如果用newInstance可以创建该类的实例,那么如下代码,我这样创建两个对象,为什么他们不能够比较相等,编译提示cannot be resolved to be a variable,求助,谢谢
try {
Foo foo=(Foo)c1.newInstance();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
Foo foo2=(Foo)c2.newInstance();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(foo==foo2);