永发信息网

java反射机制小问题

答案:1  悬赏:40  手机版
解决时间 2021-02-14 02:19
  • 提问者网友:藍了天白赴美
  • 2021-02-13 13:36
Method me = clazz.getDeclaredMethod("printf",String.class );
参数要求是String name , Class[] parameterTypes;
但是出现异常:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The type java.lang.reflect.AnnotatedElement cannot be resolved. It is indirectly referenced from required .class files
The method getDeclaredMethod(String, Class[]) in the type Class is not applicable for the arguments (String, Class<T>)
at User_reflect.main(User_reflect.java:16)
最佳答案
  • 五星知识达人网友:蓝房子
  • 2021-02-13 14:20
clazz.getDeclaredMethod("printf",String.class );
对象中没有这个方法,编译出错了

类型参数不对
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯