4

I am getting Method does not exist or incorrect signature in below method at line splitEmail.add(email.split(EMAIL_SEPARATOR))-

private static List<String> setAddress(Set<String> emailids) {        

    List<String> emailResults = new List<String>();
    List<String> splitEmail = new List<String>();

    for(String email : emailids) {
       //splitEmail = email.split(EMAIL_SEPARATOR);
       splitEmail.add(email.split(EMAIL_SEPARATOR)); 
    }

    for(String email : splitEmail) {
       emailResults.add(email.trim());
    }

    return emailResults; 
}

Why this works splitEmail = email.split(EMAIL_SEPARATOR), but not

splitEmail.add(email.split(EMAIL_SEPARATOR))

1 Answer 1

5

Because to add one list in another we use addAll so you need to do

splitEmail.addAll(email.split(EMAIL_SEPARATOR));

Split method give us a list and in first case you are assigning it to a list

splitEmail = email.split(EMAIL_SEPARATOR);

while in second case you are adding it.

List addALL

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .