Ib qho ArrayList tuaj yeem khoob (lossis nrog nulls li khoom) an tsis yog null. Nws yuav suav tias yog khoob.
Puas yog ArrayList tshiab khoob?
Tus isEmpty method of ArrayList hauv java yog siv los xyuas seb a daim ntawv yog khoob lossis tsis. Nws rov qab muaj tseeb yog tias daim ntawv teev npe tsis muaj cov ntsiab lus txwv tsis pub nws rov qab tsis tseeb yog tias daim ntawv teev npe muaj cov ntsiab lus.
Koj ua li cas los xyuas seb ArrayList tsis muaj lossis tsis muaj?
txhawm rau txheeb xyuas yog tias ArrayList khoob, koj tuaj yeem siv ArrayList. isEmpty method los yog thawj zaug xyuas yog tias ArrayList yog null, thiab yog tias tsis yog null, xyuas nws qhov loj me siv ArrayList. txoj kev loj. Qhov loj ntawm qhov khoob ArrayList yog xoom.
Nws txhais li cas yog tias ArrayList tsis muaj?
Ib qho ArrayList cov khoom tuaj yeem yog qhov khoom siv lossis tus nqi null. Thaum ib lub xovtooj muaj null, lub xovtooj tsis suav tias yog khoobDaim duab qhia cov hlwb khoob nrog "X" thiab cov hlwb uas muaj cov null nrog null. Cov hlwb uas muaj null tsis yog khoob, thiab pab txhawb rau qhov loj ntawm daim ntawv teev npe.
Can ArrayList ntxiv null hauv Java?
Yog, koj tuaj yeem siv tsis tau siv ib qho khoom. Tsuas yog ceev faj vim qee txoj kev yuav cuam tshuam yuam kev. Nws yuav yog 1. itemsList.