mardi 3 avril 2018

Getting specific array element through a getter through java.lang.reflect.Method

I am trying to use the getDeclaredMethod method from the java.lang.reflect.Method class to return a getter method which returns an array. The method works fine but I need to refer to a specific array index and that is what I have been unable to do.

 Main main = new Main();
Class m = main.getClass();
Method method;

private java.lang.reflect.Method returnMethodByName(String methodNameRMBN) throws NoSuchMethodException {
    method = m.getDeclaredMethod(methodNameRMBN, null);
    return method;
} 

And here is the method which I am getting in the Main class(It is just a standard getter):

    public int[] getColumn0() {
    return column0;
} 

This is my first post on stack overflow and I am not sure if I have provided enough information if I have not then I am happy to provide more detail.





Aucun commentaire:

Enregistrer un commentaire