Created
November 20, 2014 10:07
-
-
Save icshih/d532e02a0233910715eb to your computer and use it in GitHub Desktop.
invoke a method with parameter(s)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class[] argTypes = new Class[1]; | |
argTypes[0] = Object[].class; | |
Object[] argObj = new Object[1]; | |
argObj[0] = objs; | |
Method n = null; | |
try { | |
n = g.getDeclaredMethod("processData", argTypes); | |
} catch (NoSuchMethodException | SecurityException e1) { | |
e1.printStackTrace(); | |
} | |
try { | |
n.invoke(g.newInstance(), argObj); | |
} catch (IllegalAccessException | IllegalArgumentException | |
| InvocationTargetException | InstantiationException e1) { | |
e1.printStackTrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment