- import java.lang.reflect.*;
- class CopyAllFiles{
- public static void main(String[] args) throws Exception{
- Constructor constructor1 = A.class.getConstructor();
- A a = (A)constructor1.newInstance();
- A.class.getMethod("show", String.class).invoke(a, "hehe");
-
- }
- class A{
- public A(){}
-
- public void show(String str){
- System.out.println(str);
- }
- }
- }
复制代码 Exception in thread "main" java.lang.NoSuchMethodException: 是怎么回事呢,搞不懂了 求解惑 |
|