我在Eclipse中写了两段代码,为嘛第一个可以运行通过,第二个不行呢?- package jse03;
- public class TestReflection {
-
- public static void main(String[] args) {
- T t = new T();
- }
- }
- class T {
- T() {
- System.out.println("ttttttt");
- }
- }
复制代码- package jse03;
- import java.lang.reflect.InvocationTargetException;
- import java.lang.reflect.Method;
- public class TestReflection {
-
- public static void main(String[] args) throws ClassNotFoundException {
- Class c = Class.forName("T");
-
- }
- }
- class T {
- T() {
- System.out.println("ttttttt");
- }
- }
复制代码 |
|