You can also invoke the method, passing it the receiver and an array of
arguments:
Class sc = String.class;
Class [ ] paramTypes = new Class[1];
paramTypes[0] = sc;
try {
Method mt = sc.getMethod("concat", paramTypes);
Object mtArgs [ ] = { "xyz" };
Object result = mt.invoke("abc", mtArgs);
System.out.println("result is " + result);
} catch (Exception e) {
System.out.println("Exception " + e);
}
Here we dynamically look up a method, based both on name and type signature,
then create an array of arguments, then execute the method.