mardi 9 février 2016

Reflection Within same class [duplicate]

This question already has an answer here:

I need to call the methods within the same class dynamically. Is it a problem if I create a new instance of the same class and call the method dynamically using reflection? Or is there a way in reflection to call the method without creating an instance?

For example

public class example {
    public void callOtherMethods(String methodName) {
        // call methodName()
        // call methods of the same class dynamically
    }

    public void method1() {
        // some code
    }

    public void method2() {
        // some code
    }
    ...
}





Aucun commentaire:

Enregistrer un commentaire