package company;
public abstract class A {
public A(int i) {}
public abstract void func();
}
public class B extends A {
public B(int i) { super(i); }
public void func() {}
}
public class C extends A {
public C(int i) { super(i); }
public void func() {}
}
How do I dynamically instantiate company.C or company.B by invoking the constructor function (with a certain integer argument) and invoking the func() method? I know we can use the following method and pass an argument, but not sure how to invoke func() method on it.
You can use the Java Reflection .