反射这块还是不太清楚?

解决方案 »

  1.   

    http://topic.csdn.net/u/20080404/10/fd572e31-24bf-4472-b994-66ed1636ba3b.html78楼我有例子。
      

  2.   

    Java codepublic class TestClass {
        private int testInteger;
        private String testString;
        public TestClass(Integer testIntString testStr) {
            this.testInteger = testInt.intValue();
            this.testString = testStr;
        }
    }...try {
        Class classTestClass = Class.forName("TestClass");
        Class[] types = new Class[] {Integer.classString.class};
        Constructor constructor = classTestClass.getConstructor(types);
        Object[] args = new Object[] {123, "abc"};
        Object testClass = constructor.newInstance(args);
    } catch (Exception e) {
        e.printStackTrace();
    }