不明白你的用意?
构造什么样一个实例?getClassTypeFromParamList那个是干什么的?目前看起来只是获得了几个Class罢了,这些Class又是干什么用的呢?

解决方案 »

  1.   

    For example, I have a Class A with a constructor A(List list)
    Class A {public A(List list) {}}Now, I want to use Java reflect to create A class's instance.My problem is, as I have a parameter Object, I can know this object type. It's a concrete class not an interface, eg: I have a ArrayList object obj
    eg: Class paramType[] = new Class[]{obj.getClass()};
    constructor.getConstructor(paramType, new Object[]{obj});When I do these, it will throw NoSuchMethodException.Seams I couldn't know the relationship between its class and interface.
      

  2.   

    Perhaps u should code in this way.4 the Method getConstructor in class Class metions as follow:
    public Constructor<T> getConstructor(Class... parameterTypes)
    The parameterTypes parameter is an array of Class objects that identify the constructor's formal parameter types, in declared order.
    so,code list this.
    Class A {public A(List list) {}}
    and u got a object a.
    Class classA=a.getClass();
    Constructor con=classA.getConstructor(new Object[]{List.getClass});
    con is what u want.next time don't type in English.If you insist 2,pls type the right words make no wrong,some like "Seams"/
    The code below i haven't complie,i m busy.
    so,any issues,let me know.
      

  3.   

    It's not flexible, as you have to pass in the constuctor argument type.
    You can get it from the object you passed in.
      

  4.   

    why not use "Object" or "Object[]" as constructor parameter type? 
    Class A {public A(Object obj) {}public A(Object[] obj) {}
    }