Please forgive my Java syntax as I am a Java beginner.
I have 3 classes Main, Tool, ToolResultCallback.
class Main {
private DataList dl;
public doSomething() {
Tool t = new Tool();
ToolResultCallback TRC = new ToolResultCallback();
t.startSomething(TRC);
}
}
// in separate file
class Tool {
public void startSomething(ToolResultCallback TRC) {
}
}
// in separate file
class ToolResultCallback extends AbstractTRC {
@Override
public onEvent(SomeData d) {
// how to populate DataList of Main?
}
}
How do I populate DataList dl from callback function in another class/ file?
Pass dl to the ToolResultCallback constructor, and store it in a field.
Thanks @tgdavies
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.