* If there is any apex class with the same name of the standard or global sObjects while creating List, map,set the above error will reflect.
*We can solve this problem in two ways:
1. We have to rename our Apex Class to some other name.
2. Use 'Schema' before sObject while creating List, Set, Map (Don't use 'schema' before sObject in SOQL Query)
- List<Schema.Account> aclist = new List<Schema.Account>();
- return type should be also like List<Schema.Account>
-Click here to see the example here!
*We can solve this problem in two ways:
1. We have to rename our Apex Class to some other name.
2. Use 'Schema' before sObject while creating List, Set, Map (Don't use 'schema' before sObject in SOQL Query)
- List<Schema.Account> aclist = new List<Schema.Account>();
- return type should be also like List<Schema.Account>
-Click here to see the example here!
Refer:
Illegal assignment from LIST<Account> to LIST<Account>