Java异常————argument type mismatch
今天写程序遇到的错误
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相关推荐
- 使用java.lang.reflect.Method.invoke抛出java.lang.IllegalArgumentException: argument type mismatch异常
错误信息: java.lang.IllegalArgumentException: argument type mismatch at sun.reflect.NativeMethodAcce ...
- java argument type mismatch_解决mybatisplus插入报错argument type mismatch的问题
今天使用argument type mismatch发现插入的时候报错 java.lang.IllegalArgumentException: argument type mismatch 从错误中看 ...
- java参数错误,参数不匹配错误java.lang.IllegalArgumentException: argument type mismatch
当前位置:我的异常网» Java Web开发 » 参数不匹配错误java.lang.IllegalArgumentException 参数不匹配错误java.lang.IllegalArgumentE ...
- Cause: java.lang.IllegalArgumentException: argument type mismatch
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.Reflecti ...
- argument type mismatch
Controller层: /** * 通过学号查看学生信息 * * @return */ @RequestMapping(value = " ...
- IllegalArgumentException :argument type mismatch
上周学习的封装查询语句,今天在使用中查询语句的封装就发现了一个异常 java.Lang.IllegalArgumentException:argument type mismatch 单看名字的话应该 ...
- mybatis plus argument type mismatch
异常信息 项目中使用了mybatis-plus,一个功能,昨天还使用的好好的,今天突然就不能用了,控制台还报错 argument type mismatch java.lang.illegalArgu ...
- Struts Form中Date类型之“argument type mismatch”错误解决方法
现象: 当输入页面中含有日期如2008-01-01时,如果Form中对于的字段为Date类型,则会出现"argument type mismatch"错误. 原因: Struts的 ...
- IllegalArgumentException:argument type mismatch
Exception nested exception is org.apache.ibatis.reflection.ReflectionException: Could not set proper ...
最新文章
- 令人迷惑的ATT的jmp:直接跳转和间接跳转 [转]
- 读写锁ReadWriteLock
- 类选择器与ID选择器的比较
- 【拔刀吧少年】之Expect 自动化控制和测试 Here Document 免交互
- Edit button clicked in offline mode
- Eclipse关闭XML文件验证的方法
- Illumina联手IBM Watson Health解读癌症基因谱
- 第9章 SportsStorePeta 完成购物车
- html巡检脚本,WEB服务器巡检脚本
- ASP.NET MVC . Controller
- 翻译: Swift 中的委托保留周期 如何在“纯”Swift(没有@objc)中进行弱协议引用
- Druid-1.1.12.jar下载 (链接下载+使用)
- 谷歌插件无法显示在地址栏右侧
- 取色工具ColorPix
- Ubuntu下安装配置Honeyd蜜罐
- wpf DataGrid 绑定数据源后多一列
- Python代码实现信息轰炸
- nodejs+vue结合七牛云实现图片上传
- greenplum创建外部表笔记-readable篇
- Unreal Engine 4 —— Smear Frame效果的实现与分析
热门文章
- 使用 Task.Wait()?立刻死锁(deadlock)
- 当OA遇上鸿蒙,打开信创智慧办公新画卷
- POSTGRESQL 差点发生一次冻结炸弹后的反思
- yii2 aliases web.php,别名(Aliases) - Yii2 权威指南
- 解锁教爸妈使用智能手机的新方法!
- webstorm如何自动修复prettier提示的错误
- 把你问到哑口无言,HR是专业的!
- MFC关于*.rc和resource.h文件的巧妙运用
- 山东省技能兴鲁职业技能竞赛-人工智能工程技术人员
- b站服务器崩溃大会员自动续费,[财经]B站因服务器故障赠送用户1天大会员!回应补偿会自动续费会退款 - 南方财富网...