dimanche 21 février 2016

Getting the values passed to an instance method

I have a method that I want to be able to tell what values are passed to it each time it is called.

For instance:

public void doStuff(String val1, int val2) {

}

public static void main(String[] args) {
    doStuff("Hello", 5);
    doStuff("There", 6);
}

Now I realize I could just print val1 and val2 but what I would like to do is be able to do this using something along the lines of reflection. I can currently grab the type but I am not sure how to grab the actual value passed to a specific instance.





Aucun commentaire:

Enregistrer un commentaire