You need to sign in to do that
Don't have an account?
Syed Aswan 5
Illegal assignment from List<Account> to List<Account> at line 6 column 9
Can anyone tell me what is the error in the following code, I'm getting the above error:
Public class AccountUtils
{
List<Account> accountsByState (String Str)
{
List<Account> accList = new List<Account>();
accList=[SELECT ID,name from Account where BillingState=:Str];
return accList;
}
}
Public class AccountUtils
{
List<Account> accountsByState (String Str)
{
List<Account> accList = new List<Account>();
accList=[SELECT ID,name from Account where BillingState=:Str];
return accList;
}
}
You code look good to me. Can you please you have any apex class with Account Name if yes then please rename or delete that class and try again above code.
Please let us know if this will help you
Thanks
AMit Chaudhary
All Answers
You code look good to me. Can you please you have any apex class with Account Name if yes then please rename or delete that class and try again above code.
Please let us know if this will help you
Thanks
AMit Chaudhary
In your organization somewhere you have created a class named "Account". Thats why the compiler is not able to understand that it is standard Object Account or the class created by you. Please rename your class, it will work.
Or you can assign your list with prefixing with "Schema"
Try working on your class:
Hope this helps you!
Best Regards,
Deepthi
Thanks it worked.
I have tried and its working fine. e.g:
AccountUtils ac=new AccountUtils();
List<Account> acList=ac.accountsByState('GenePoint');
System.debug('output is'+acList);
OUTPUT:
output is(Account:{Id=0012800000QvVY3AAN, Name=GenePoint})