【发布时间】:2015-10-25 02:07:23
【问题描述】:
我的项目中有这样的代码:
public class MyExpAdapter extends BaseExpandableListAdapter
{
@Override
public int getChildrenCount(final int groupPosition)
{
return this.getCountry(groupPosition) == null ? 0 :
this.getCountry(groupPosition).getCityList() == null ? 0 :
this.getCountry(groupPosition).getCityList().size();
}
.
.
.
}
虽然我正在检查空概率,但检查员仍然突出显示最后两行,如下图所示。任何想法?谢谢。
更新
【问题讨论】:
-
尝试在代码中添加大括号。 Java 可能会打乱运算符的顺序。
-
getCountry 列表可能为空。
-
在没有三元运算符的情况下会发生这种情况吗?
标签: java android android-studio nullpointerexception inspector