I have a method that return a list of objects and I want to call it by the invoke method of the class Method. The only problem is that invoke method returns an Object
and not a list<Object>
.
The code is here:
Class<? extends AnObject> anObject = MyObject.getClass();
Method myMethod = MyObject.getMethod("getListObject");
Object objject = method.invoke(MyObject); // I want it to return list
How can I solve it?