Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IllegalArgumentException: wrong number of arguments
- import java.lang.reflect.InvocationTargetException;
- import java.lang.reflect.Method;
- public class Reflection {
- /**
- * @param args
- * @throws InvocationTargetException
- * @throws IllegalArgumentException
- * @throws IllegalAccessException
- */
- public static void main(String[] args) throws IllegalAccessException,
- InvocationTargetException, IllegalArgumentException {
- Class<Cls> cls = Cls.class;
- Method[] methods = cls.getMethods();
- for (Method m : methods) {
- m.invoke(cls);
- }
- }
- }
- class Cls {
- public static void method1() {
- System.out.println("Method1");
- }
- public static void method2() {
- System.out.println("Method2");
- }
- }
- m.invoke(cls, null);
Add Comment
Please, Sign In to add comment