For example, I have a class with a method
public class SomeClass {
public void someMethod(Object arg) {
//some code
}
}
And I obtained method through reflection in another class:
SomeClass instance = new SomeClass();
Method method = someClass.class.getMethod();
Is there any way to put it to a Consumer<Object>
and then use with Consumer.accept()
, or do I have to use something like this:
Consumer<Object> consumer = object -> method.invoke(instance, new Object())
Aucun commentaire:
Enregistrer un commentaire