Bro*_*der 32 java null long-integer
如何在Java中检查null的Long值?
这会有用吗?
if ( longValue == null) { return blah; }
Run Code Online (Sandbox Code Playgroud)
brs*_*o05 77
原始数据类型不能null.只有Object数据类型可以null.
int,long等等......不可能null.
如果您使用Long(包装类long),那么您可以检查null's:
Long longValue = null;
if(longValue == null)
Run Code Online (Sandbox Code Playgroud)
如果longValue变量是类型Long(包装类,而不是基元long),那么是的,您可以检查空值.
原始变量需要显式初始化为某个值(例如to 0),因此其值永远不会为null.
小智 7
您可以使用 来检查 Long 对象的空值longValue == null,也可以 longValue == 0L用于 long(原始),因为 long 的默认值为 0L,但如果 longValue 也为零,则结果将为 true
| 归档时间: |
|
| 查看次数: |
151200 次 |
| 最近记录: |