在下面的代码中
queryCmisAdvance.getAdvanceKeywords()
返回 AdvancePropertyKeywords 类的 ArrayList
在类 AdvancePropertyKeywords
一共有三个参数String Property Name , condition and value.
有时值可能是“”(并且这不为空)
现在我想检索其值不是 ""的 propertyName 。
我的代码
for(AdvancePropertyKeywords apk : queryCmisAdvance.getAdvanceKeywords()){
if (apk.getValue()!="" ) {
System.out.println(apk.getPropertyName() +" " +apk.getCondition() + " "+apk.getValue());
}
}
输出
From =
SentOn > Wed Aug 22 12:00:00 UTC+2 2012
EmailSubject LIKE folder
DocumentTitle NULL rgftre
CarbonCopy LIKE
<小时/>
From value is ""
SentOn value is Wed Aug 22 12:00:00 UTC+2 2012
EmailSubject value is folder
DocumentTitle value is rgftre
CarbonCopy value is ""
最佳答案
使用equals()
方法而不是 !=
运算符(operator)。 equals()
方法比较对象内容,而 ==
和!=
运算符比较 object reference values
如果是 Object Comparision
。请参阅以下代码:
for(AdvancePropertyKeywords apk : queryCmisAdvance.getAdvanceKeywords()){
if (!"".equals(apk.getValue()) {
System.out.println(apk.getPropertyName() +" " +apk.getCondition() + " "+apk.getValue());
}
}
关于java - 获取ArrayList值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11882094/