2

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))
2

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

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.