package com.kvku.test;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
public class ArrayListTest {
public static void main(String[] args) throws NoSuchMethodException,
SecurityException, IllegalAccessException,
IllegalArgumentException, InvocationTargetException {
ArrayList<Integer> list = new ArrayList<Integer>();
Class c = list.getClass();
Method method = c.getMethod("add", Object.class);
method.invoke(list, "hello");
method.invoke(list, "world");
System.out.println(list);
}
}
|