码上敲享录 > java入门知识分享 > 解决 attempted to return null from a method with a primitive return type (int).

解决 attempted to return null from a method with a primitive return type (int).

上一章章节目录下一章 2019-10-16已有2928人阅读 评论(0)

java后台代码报错

attempted to return null from a method with a primitive return type (int).

解决方法:

在java,mybatis查询时,当返回查询的条数。当返回为null的时候,就报错了。查找原来是定义了int接收返回的条数,而int的初值为0,Ingeter的初值为null;所以应将int改为null

四、int和integer的区别

1. Ingeter是int的包装类,int的初值为0,Ingeter的初值为null;

2.初始化的时候,int i = 1;Integer i= new Integer(1);(要把integer 当做一个类看);但由于有了自动装箱和拆箱使得对Integer类也可使用:Integer i= 1;    

3.int 是基本数据类型,Integer 是一个类,是int的扩展,定义了很多的转换方法

4.Integer是对象,用一个引用指向这个对象,而int是基本类型,直接存储数值。



向大家推荐《Activiti工作流实战教程》:https://xiaozhuanlan.com/activiti
0

有建议,请留言!

  • *您的姓名:

  • *所在城市:

  • *您的联系电话:

    *您的QQ:

  • 咨询问题:

  • 提 交