本帖最后由 李哲 于 2012-4-10 21:23 编辑
- import java.lang.reflect.Constructor;
- import java.util.ArrayList;
- public class CopyOfReflectTest1
- {
- public static void main(String[] args) throws Exception
- {
- //Constructor c3=Person1.class.getConstructor(int.class); //为什么这语句会出错,下面的语句就不会?
-
- Constructor c1=String.class.getConstructor(StringBuffer.class);
-
-
- }
-
- }
- class Person1
- {
- int age;
- private String name;
- Person1(int age)
- {
- this.age=age;
- }
- public void setName(String name)
- {
- this.name=name;
- }
- public String getName()
- {
- return name;
- }
- public String toString()
- {
- return this.name;
- }
- }
复制代码 |
|