本帖最后由 傅宇 于 2013-3-13 13:18 编辑
- import java.lang.reflect.Constructor;
- import java.lang.reflect.InvocationTargetException;
- public class ts1 {
- public static void main(String[] args) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
- Constructor cons1 = String.class.getConstructor(StringBuffer.class);
- String str = (String)cons1.newInstance("abc");
- System.out.println(str.charAt(2));
- }
- }
复制代码 为什么会报IllegalArgumentException: argument type mismatch?求解! |