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
Suresh(Suri)Suresh(Suri) 

not getting list of accounts

Hi All

 

Please see following code.

public class samp 
{
public list<contact> clist=new list<contact>();
public list<Account> alist=new list<Account>();
public samp()
{
for(contact c:[select department,Languages__c, id,name from contact])
{
clist.add(c);
}
for(account a:[select id from account])
{
alist.add(a);
}
}

public list<contact> getcontactlist()
{
return clist;
} 




}

 I am getting following error .please solve my problem,



 

 


 
Error: samp Compile Error: Loop variable must be an SObject or list of Account at line 11 column 13

 

 

thank you in advance

aballardaballard

I just tried that and it saved without error for me. 

 

Do you have something else defined that is interferinf with it?  An apex class called Account perhaps?

Ankit AroraAnkit Arora

Nothing wrong with code. Are you sure this is the complete code and you are facing erro while savinf the class?

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page