lundi 2 juillet 2018

Java - Invoke method implicitly (Reflection?) [duplicate]

This question already has an answer here:

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