永发信息网

The operator + is undefined for the argument type(s) Integer, int的报错处理

答案:2  悬赏:60  手机版
解决时间 2021-11-27 13:08
  • 提问者网友:最美的风景
  • 2021-11-27 02:10
The operator + is undefined for the argument type(s) Integer, int的报错处理
最佳答案
  • 五星知识达人网友:污到你湿
  • 2021-11-27 02:57
int id = (maxId == null ? 1 : ((Integer) maxId).intValue() + 1) 这样写 可能你的jdk版本问题
或者改成下面这个样子也是可行的

int maxId =-1;
maxId = super.selectOnlyValue("select max(id) from tb_album");
int id = (maxId == -1? 1 : maxId + 1);
super.longHaul("insert into tb_album(id,father_id,name) values(" + id + "," + fatherId + ",'" + name + "')");
return id;追问谢谢,我用的是JDK1.8的应该没什么问题,直接用Intvalue取值已经没有报错了,接下去会继续测试,已经采纳,谢谢~
全部回答
  • 1楼网友:归鹤鸣
  • 2021-11-27 03:20
null只能对应指针,改为int*试试
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯