This question already has an answer here:
- Intercepting method calls 4 answers
That's what I wanna do. Suppose a class Target
with some method:
class Target {
public void targetMethod() {}
}
And class Listener
that somehow should know when targetMethod()
is invoked:
class Listener {
public static void listenForTargetMethod() {
//code executes when targetMethod() is invoked
}
}
Is it even possible and how to implement this? (without calling listenForTargetMethod()
explicitly)
Aucun commentaire:
Enregistrer un commentaire