开发者

How to check element is not null in java

filterItems = null;
filterItems = new ArrayList<SelectItem>();


Iterator<String> it = RefListMap.keySet().iterator();
        while (it.hasNext()) {
            String s = (String) it.next();
        开发者_如何学Go    filterItems.add(new SelectItem(s, s));
        }

Now i am getting filterItems size=1 but that value is null.How to check array element is not equal to null.

if(filterItems != null)
{

 code
}

but this condition is not working...Please help me.


try:

String s = (String) it.next();
if(s != null){
    filterItems.add(new SelectItem(s, s));
}


Presumably the value you're getting from the RefListMap is null. You might check whether s was null before you add it to filterItems.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜