function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
srinivas pulipatisrinivas pulipati 

hi i am writing apex program and vf program but error is came how to solve this error


public class ListExamples {
    public set<string> name{set;get;}
    public ListExamples(){
        List <string> mylist =new List<String>();
        mylist.add('sakthi');
        mylist.add('sreenu');
        mylist.add('vamsi');
        set<String> name = new set<string>();
        name.add('one');
        name.add('two');
        name.add('three');
        name.addAll('mylist');
    }
    }
Vf Pgae:

<apex:page controller="ListExamples" >
    <apex:form >
        <apex:pageblock >
         <apex:pageBlockTable value="{!name}" var="a">
             <apex:column colspan="2" value="{!a}"/>
        </apex:pageBlockTable>
        </apex:pageblock>
    </apex:form>
</apex:page>


Error:
Method does not exist or incorrect signature: [Set<String>].addAll(String)
William TranWilliam Tran
Srinivas,

You syntax is wrong:

Change this:

     name.addAll('mylist');

To this (remove the single quotes):

     name.addAll(mylist);

Thx
srinivas pulipatisrinivas pulipati
Tq u
William TranWilliam Tran

Srinivas,  it looks like you are new to this forum,

As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.

Good luck!!!

Thanks