先定义回调接口:
public interface CallBack {
public void execute();
}
public class TestCallBack {
public static void testCallBackMethod(CallBack callBack){
System.out.println("Before call back");
//call back
callBack.execute();
System.out.println("After call back");
}
public static void main(String[] args) {
TestCallBack.testCallBackMethod(new CallBack(){
public void execute() {
System.out.println("callBack1 operation over");
}
});
}
}