...
Code Block |
---|
public interface CallBack { void callMethod(); } class MyCallBackCallBackImpl implements CallBack { public void callMethod() { System.out.println("CallBack invoked"); } } class Client { CallBack callback; public void registerCallBack(CallBack callback) { this.callback = callback; } public void doSomething() { callback.callMethod(); } public static void main(String[] args) { Client client = new Client(); client.registerCallBack(new MyCallBackCallBackImpl()); // ... client.doSomething(); // prints "CallBack invoked" } } |
...