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
Charms MobCharms Mob 

When to Use List

Hi Developer,

I have written a sample piece of code .Here it is 

Public class TotalPrice_cls{
public static void calTotal(Book__c[] b)
{
for(Book__c[] s: b)
s.Total_Price__c = s.Price__c* s.Quantity__c;

}
}
While running the code it displays the error message as :Error: Initial term of field expression must be a concrete SObject: LIST<Book__c> at line 9 column 1.
May i know the reason for this error message. Thanks in advance.
Best Answer chosen by Charms Mob
Sindhu1234Sindhu1234
Here you go...

change For(Book__c[]s:b)  to  for(Book__c  s : b);

The reason here is using for loop your sending one record at a time not an array of record. If its an array/collection go with list.