A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 寇弘禄 中级黑马   /  2013-2-26 20:23  /  2078 人查看  /  4 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

照着张老师的写的,我这个运行怎么报错?
  1. public class Test {

  2.         /**
  3.          * @param args
  4.          * @throws NoSuchMethodException
  5.          * @throws SecurityException
  6.          */
  7.         public static void main(String[] args) throws SecurityException, NoSuchMethodException {
  8.                 // TODO Auto-generated method stub
  9.                 Method applyMethod = Test.class.getMethod("applyVetor",Vector.class);
  10.                 Type[] types = applyMethod.getGenericParameterTypes();
  11.                 ParameterizedType pType = (ParameterizedType)types[0];
  12.                 System.out.println(pType.getRawType());
  13.                 System.out.println(pType.getActualTypeArguments()[0]);
  14.         }
  15.         public static void applyVector(Vector<Date> v1){
  16.                
  17.         }
  18. }
复制代码

4 个回复

倒序浏览
Method applyMethod = Test.class.getMethod("applyVetor",Vector.class);
方法名找不到的异常...

改成

Method applyMethod = Test.class.getMethod("applyVector",Vector.class);
回复 使用道具 举报
Method applyMethod = Test.class.getMethod("applyVetor",Vector.class);这里的applyVetor应该是appleyVector,拼写错误
回复 使用道具 举报
赵文 发表于 2013-2-26 21:02
Method applyMethod = Test.class.getMethod("applyVetor",Vector.class);
方法名找不到的异常...

哦 谢谢 确实是方法名错了,刚才看了半天没看出来。
回复 使用道具 举报
黑马刘杰 发表于 2013-2-26 21:04
Method applyMethod = Test.class.getMethod("applyVetor",Vector.class);这里的applyVetor应该是appleyVec ...

恩 谢谢,是这错了。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马