判断int或Integer变量值为空值null
•
数据库
1.int型变量的值不能为空值null
2.Integer类表示一个int值,但可以包含一个空值null
3.判断Integer变量是否为空值null:Integer变量== null;Integer变量!= null
demo示例程序如下:
public class Demo {
public static void main(String[] args) {
// 如果在后面判断int 类需==null 或!=null的情况下,可以将int类型改为Integer类型
// int i = null; // 打开本行注释将无法通过编译,int的值不能为空值null
Integer in = null; // Integer类表示一个int值,但可以包含一个空值null
// in = 1; // 赋一个int值
System.out.println(in == null);
}
}
运行结果:
本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/de04724f5a.html
