检查Java Android中的VectorObject是否为空或Null
我想检查矢量对象在ANDROID中是否为空或Null检查Java Android中的VectorObject是否为空或Null,java,android,object,vector,nullpointerexception,Java,Android,Object,Vector,Nullpointerexception,我想检查矢量对象在ANDROID中是否为空或Null if(vectorCustRecipetDB != null && vectorCustRecipetDB.size() != 0) { for (int i = 0; i < vectorCustRecipetDB.size(); i++) { Some Code } } if(vectorCustRecipetDB!=null&&vectorCustRecipe
if(vectorCustRecipetDB != null && vectorCustRecipetDB.size() != 0)
{
for (int i = 0; i < vectorCustRecipetDB.size(); i++) {
Some Code
}
}
if(vectorCustRecipetDB!=null&&vectorCustRecipetDB.size()!=0)
{
对于(int i=0;i
但我得到了空指针异常。请帮助。堆栈跟踪在哪里??或
logcat
?这些行不会导致NPE。发布异常和包含违规行的代码。使用您提供的代码不可能。好的,我知道了。问题出在这行txtCustRecCardRouteNo.setText(vectorCustRecipetDB.get(i).route_No);我得到的路径号为null。实际上问题是我在初始化txtCustRecCardRouteNo之前设置了文本。这就是为什么我会犯这个错误。Thnx@ZouZou问题解决了。