interface Callback{
void call();
}
class A implements Callback{
private B b;
public A(){
b = new B();
b.registerCallback(this);
}
// Implementation of the callback interface
public void call(){
}
}
public class B
{
private Callback callbackoNotify;
public class registerCallback(Callback callback)
{
callbackoNotify = callback;
}
public void doTask()
{
//do some stuff...
callbackNotify.call();
}
}
Recommended Posts