此处报错 if (users.getUsersid() != null)
The operator != is undefined for the argument type(s) long, null
通过Ctrl+左键找到错误源
private long usersid;
public long getUsersid() {
return this.usersid;
}
应该是Long
改正之后
private Long usersid;
public Long getUsersid() {
return this.usersid;
}
The operator != is undefined for the argument type(s) long, null
通过Ctrl+左键找到错误源
private long usersid;
public long getUsersid() {
return this.usersid;
}
应该是Long
改正之后
private Long usersid;
public Long getUsersid() {
return this.usersid;
}
本文解决了一个关于使用不正确的类型进行非等价比较的问题。原本使用了基本类型long,在需要进行null检查的情况下应该使用包装类型Long。通过更改变量类型及getter方法返回类型,解决了潜在的空指针异常。
5435

被折叠的 条评论
为什么被折叠?



