<分区>
将已定义的 int 设置为 null 的最佳方法是什么?
private int xy(){
int x = 5;
x = null; //-this is ERROR
return x;
}
所以我选择了这个
private int xy(){
Integer x = 5;
x = null; //-this is OK
return (int)x;
}
然后我需要类似的东西:
if(xy() == null){
// do something
}
我的第二个问题是我可以安全地将 Integer 转换为 int 吗?
感谢您的回复。