I have array with list of class.

public class filterField {
    public String label {get;set;}
    public String searchFieldName {get;set;}
    public String searchValue {get;set;}

    public filterField(String a,String b,String  c) {
        this.searchFieldName =b;
        this.searchValue  =c;


public filterField [] filterArray {get;set;}
filterArray = new filterField[]{};

FilterArray is list of class. I try to get the value of class string values. I tried below.


for(integer i=0;i<filterArray.size();i++) {
    system.debug('value insude for:::::'+filterArray.get(i).searchValue);

    string s=filterArray.get(i).searchValue;

    if(filterArray.get(i).searchValue!=null || filterArray.get(i).searchValue!='') {

        system.debug('value ins:::::'+filterArray.get(i).searchValue);
        String strField=filterArray.get(i).searchFieldName +':'+'"'+filterArray.get(i).searchValue+'"';

My array values are :

filterField:[label=AccountName, searchFieldName=FULL_NAME, searchValue=], 
filterField:[label=City, searchFieldName=PRIM_CITY, searchValue=test], 
filterField:[label=Country, searchFieldName=PRIM_COUNTRY_NM, searchValue=], 
filterField:[label=Street Address, searchFieldName=PRIM_ADDR_LN_1, searchValue=], 
filterField:[label=State/Province, searchFieldName=PRIM_STATE, searchValue=test], 
filterField:[label=Zip/PostalCode, searchFieldName=PRIM_POSTAL_CD, searchValue=]
  • 2
    String.isBlank(someString); – d_k Apr 26 '17 at 8:33

Use String.isBlank(yourString) to check if it's null or '' or ' '. This method detects whether string has null or blank space or just quotes.


String str = 'searchValue';
System.assertEquals(false,String.isBlank(str));   // returns false since string is not blank
| improve this answer | |

String.isEmpty(yourString); isEmpty method will also help in checking.

| improve this answer | |
  • 4
    Important to not the different is that this method does NOT detect a sting containing only whitespace when compared to isBlank – Eric Apr 26 '17 at 14:20
  • Agreed with eric – Sharp Dixit Apr 26 '17 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.