[英]Can Parent Class call Dynamically created child class method in java?
I want to call method of dynamically created child method from parent and than pass values to that class. 我想从父级调用动态创建的子方法的方法,然后将值传递给该类。
This is possible in java? 这可能在Java中吗?
Class Parent {
Child(1, 2, ..., N).someMethod();
}
//Dynamically created at any time and also deleted
Class Child1 { }
Class Child2 { }
.
.
.
Class ChildN { }
sure 当然
Class Parent{
Child child;
// setup child somehow
public void callChildMethod(){
child.callMethod();
}
}
just make sure child is overriding the method callMethod(); 只需确保child覆盖方法callMethod();即可。
ps: you better present some example you need on domain you understand. ps:您最好在了解的域上提供一些所需的示例。 Second: this is not java question
第二:这不是java的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.