java反射机制的问题
1. package com.zxn.example;
2.
3. import java.lang.reflect.Constructor;
4.
5. public class MainClass
6. {
7. public static void main(String[] args)
8. {
9. try
10. {
11. // find the class and the constructor
12. Class cls = Class.forName("com.zxn.example.MyClass");
13. Class[] paramDef = new Class[]{ String.class, String.class };
14. Constructor constructor = cls.getConstructor( paramDef );
15.
16. // create a new instance by using the constructor
17. Object[] params = new Object[]{ "userName", "password" };
18. MyClass clsInstance = (MyClass)constructor.newInstance(params);
19.
20. // call the test() method of the class
21. clsInstance.test();
22. }
23. catch (Exception e)
24. {
25. System.out.println(e.getMessage());
26. }
27. }
28. }
这是java的反射机制去访问我另外一个包中的MyClass类中的构造方法,(看的例子),不知道第13行是什么意思?他是创造一个新的实例么?不知道什么意思,附上连接地址http://www.javaeye.com/wiki/topic/482281