首页 > 编程知识 正文

java.util.arraylist cannot be(判断object是否为null)

时间:2023-05-03 13:54:43 阅读:70009 作者:2938

thisclassconsistsofstaticutilitymethodsforoperatingonobjects。

oneofsuchmethodsisobjects.is null (。

myunderstandingisthatobjects.is null (wouldremovethechanceofaccidentallyassigninganullvaluetoobjectbyomitttingthesecond=.

However,the API Note states:

thismethodexiststobeusedasapredicate,filter(Objects3360:isnull ) )。

wouldtherebeanyreason/circumstanceforwhichishoulduseobject==nulloverobjects.is null (inanifstatement?

should objects.is null (beconfinedtopredicatesexclusively?

shoulduseobject==nulloverobjects.is null (inaifstatement?

ifyoulookatthesourcecodeofisnullmethod,

/* returnstrueiftheprovidedreferenceisnullotherwisereturnsfalse.* /

publicstaticbooleanisnull (objectobj ) {

返回obj==null;

}

itis the same.thereisnodifference.soyoucanuseitsafely。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。