H
homecurr
public interface IA{...}
public class A implements IA{...}
public class F{
public F(IA ia){...}
}
If I do this:
A a = new A();
F f = new F(a);
It works fine. But if I do this:
A a = new A();
Class clazz = Class.forName("F");
Constructor constructor = clazz.getConstructor(new Class[]{a.getClass()});
The last line does not work because F does not have a constructor like F(A){}.
Why? How can I fix it? I have to use the reflection in my project.
Thanks,
John
public class A implements IA{...}
public class F{
public F(IA ia){...}
}
If I do this:
A a = new A();
F f = new F(a);
It works fine. But if I do this:
A a = new A();
Class clazz = Class.forName("F");
Constructor constructor = clazz.getConstructor(new Class[]{a.getClass()});
The last line does not work because F does not have a constructor like F(A){}.
Why? How can I fix it? I have to use the reflection in my project.
Thanks,
John