0

In below code

queryCmisAdvance.getAdvanceKeywords() returns ArrayList of class AdvancePropertyKeywords

In Class AdvancePropertyKeywords

there are Three Parameter String Property Name , condition and value.

Some time it is possible that value can be "" (and this is not null)

and now i want to retrive the propertyName whose value is not "" .

My code

   for(AdvancePropertyKeywords apk : queryCmisAdvance.getAdvanceKeywords()){

                if (apk.getValue()!="" ) {
                    System.out.println(apk.getPropertyName() +" " +apk.getCondition() + " "+apk.getValue());
                }
            }

outPut

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 ""
Nandkumar Tekale
  • 16,024
  • 8
  • 58
  • 85
GameBuilder
  • 1,169
  • 4
  • 31
  • 62
  • 4
    Don't compare Strings with "!=". Use .equals(). See http://stackoverflow.com/questions/767372/java-string-equals-versus . – Dan Gravell Aug 09 '12 at 11:22

2 Answers2

1

Use equals() method instead of != operator. equals() method compares object contents while == and != operators compare object reference values in case of Object Comparision. See following code :

for(AdvancePropertyKeywords apk : queryCmisAdvance.getAdvanceKeywords()){
     if (!"".equals(apk.getValue()) {
         System.out.println(apk.getPropertyName() +" " +apk.getCondition() + " "+apk.getValue());
     }
}
Nandkumar Tekale
  • 16,024
  • 8
  • 58
  • 85
0

@DanGravell : thanks , this works.

if (!(apk.getValue().equals(""))) {
                System.out.println(apk.getPropertyName() +" " +apk.getCondition() + " "+apk.getValue());
}
GameBuilder
  • 1,169
  • 4
  • 31
  • 62