package com.liu.callBack;
public interface CallBackInterface2 {
/**
* 回调接口函数
*
*/
public void CallBackFunc();
}
package com.liu.callBack;
public class CallBackTest2 {
public static void main(String[] args) {
// new a main Object
CallBackTest2 cbt = new CallBackTest2();
// call back
cbt.CallCallBackFunc2(new CallBackInterface2() {
/**
* 回调函数,不是通过接口的实现类来实现,通过匿名类来访问。
*/
public void CallBackFunc() {
String str = "this is a callBackFunc";
System.out.println("Print in Call Back function:" + str);
}
});
}
/**
*
* @param cbi
* 回调函数,调用接口中的要实现的方法。。。。
*/
public void CallCallBackFunc2(CallBackInterface2 cbi) {
cbi.CallBackFunc();
}
}