今天写程序遇到的错误

Exception in thread "main" java.lang.IllegalArgumentException: argument type mismatch

argument type mismatch---》参数类型不匹配

直接上代码

public class Student {private String name;private int age;//私有的有参构造方法private  Student(String name){System.out.println("name的值为"+name);System.out.println("private....Student...有参构造方法");}//公共的无参构造方法public Student(){System.out.println("public...student...无参构造方法");}//公共的有参构造方法public Student(String name,int age){System.out.println("name的值"+name+"age的值为"+age);System.out.println("public。。。Student...有参构造方法");}
}

测试类:

public class test2 {public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {//T newlnstance(Object...initargs):根据指定的构造方法创建对象//1.获取class对象Class aClass = Class.forName("com.sx.first.reflect2.Student");//2.获取构造方法对象Constructor constructor = aClass.getConstructor(String.class, int.class);//3.利用newlnstance创建对象Student student = (Student) constructor.newInstance("zhangsan", "23");System.out.println(student);}
}

本人一学渣,报的错误一下懵了没看懂,程序也没有报错,自己看了好久才发现

Student student = (Student) constructor.newInstance("zhangsan", "23");

这一行在学生类是int类   而我写参数的时候加了"23"  ,但是一值没有报错    哈哈哈哈希望大家注意  还有就是以后Mybatis 和数据库连接的时候有可能也会出现这个问题    加油

Java异常————argument type mismatch相关推荐

  1. 使用java.lang.reflect.Method.invoke抛出java.lang.IllegalArgumentException: argument type mismatch异常

    错误信息: java.lang.IllegalArgumentException: argument type mismatch     at sun.reflect.NativeMethodAcce ...

  2. java argument type mismatch_解决mybatisplus插入报错argument type mismatch的问题

    今天使用argument type mismatch发现插入的时候报错 java.lang.IllegalArgumentException: argument type mismatch 从错误中看 ...

  3. java参数错误,参数不匹配错误java.lang.IllegalArgumentException: argument type mismatch

    当前位置:我的异常网» Java Web开发 » 参数不匹配错误java.lang.IllegalArgumentException 参数不匹配错误java.lang.IllegalArgumentE ...

  4. Cause: java.lang.IllegalArgumentException: argument type mismatch

    org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.Reflecti ...

  5. argument type mismatch

    Controller层: /**      * 通过学号查看学生信息      *       * @return      */     @RequestMapping(value = " ...

  6. IllegalArgumentException :argument type mismatch

    上周学习的封装查询语句,今天在使用中查询语句的封装就发现了一个异常 java.Lang.IllegalArgumentException:argument type mismatch 单看名字的话应该 ...

  7. mybatis plus argument type mismatch

    异常信息 项目中使用了mybatis-plus,一个功能,昨天还使用的好好的,今天突然就不能用了,控制台还报错 argument type mismatch java.lang.illegalArgu ...

  8. Struts Form中Date类型之“argument type mismatch”错误解决方法

    现象: 当输入页面中含有日期如2008-01-01时,如果Form中对于的字段为Date类型,则会出现"argument type mismatch"错误. 原因: Struts的 ...

  9. IllegalArgumentException:argument type mismatch

    Exception nested exception is org.apache.ibatis.reflection.ReflectionException: Could not set proper ...

最新文章

  1. 令人迷惑的ATT的jmp:直接跳转和间接跳转 [转]
  2. 读写锁ReadWriteLock
  3. 类选择器与ID选择器的比较
  4. 【拔刀吧少年】之Expect 自动化控制和测试 Here Document 免交互
  5. Edit button clicked in offline mode
  6. Eclipse关闭XML文件验证的方法
  7. Illumina联手IBM Watson Health解读癌症基因谱
  8. 第9章 SportsStorePeta 完成购物车
  9. html巡检脚本,WEB服务器巡检脚本
  10. ASP.NET MVC . Controller
  11. 翻译: Swift 中的委托保留周期 如何在“纯”Swift(没有@objc)中进行弱协议引用
  12. Druid-1.1.12.jar下载 (链接下载+使用)
  13. 谷歌插件无法显示在地址栏右侧
  14. 取色工具ColorPix
  15. Ubuntu下安装配置Honeyd蜜罐
  16. wpf DataGrid 绑定数据源后多一列
  17. Python代码实现信息轰炸
  18. nodejs+vue结合七牛云实现图片上传
  19. greenplum创建外部表笔记-readable篇
  20. Unreal Engine 4 —— Smear Frame效果的实现与分析

热门文章

  1. 使用 Task.Wait()?立刻死锁(deadlock)
  2. 当OA遇上鸿蒙,打开信创智慧办公新画卷
  3. POSTGRESQL 差点发生一次冻结炸弹后的反思
  4. yii2 aliases web.php,别名(Aliases) - Yii2 权威指南
  5. 解锁教爸妈使用智能手机的新方法!
  6. webstorm如何自动修复prettier提示的错误
  7. 把你问到哑口无言,HR是专业的!
  8. MFC关于*.rc和resource.h文件的巧妙运用
  9. 山东省技能兴鲁职业技能竞赛-人工智能工程技术人员
  10. b站服务器崩溃大会员自动续费,[财经]B站因服务器故障赠送用户1天大会员!回应补偿会自动续费会退款 - 南方财富网...