public interface Callback{
void call();
}
public abstract class task{
final void executeWith(Callback callback) {
execute();
callback.call();
}
public abstract void execute();
}
public class DefaultTask extends Task {
@Override
public void execute() {
}
}
var task = new DefaultTask();
task.executeWith(()-{
System.out.println("task finished“);
})
Callback+模板方法
最新推荐文章于 2024-09-02 20:28:23 发布